ruby-on-rails-3

undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)

痴心易碎 提交于 2020-01-20 03:11:54
问题 I am working on rails, suddenly rails server stops working. It's working fine and I have used following command [platform windows 7] gem install -v=2.3.5 rails And when I use rails s , it's giving the following error: c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails_generator/options.rb:32:in `default_options': undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError) from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails_generator/base

Ruby/Rails: Converting datetime to natural language (e.g. 3/23/2012 to “this Friday”)

守給你的承諾、 提交于 2020-01-20 02:47:11
问题 Is anyone aware of a gem, method, or code snippet that will convert datetime values into sometime more human-friendly without having to create a series of rules or put a bunch of logic in the view? For example: if today is 3/19/2012, convert: 3/23/2012 to “This Friday” 3/26/2012 to “Next Monday” 3/31/2012 to “Next weekend” 4/15/2012 to “Next month” 3/15/2012 to “Last Thursday” 3/01/2011 to “Last year” Basically, I’m looking for the opposite of the Chronic gem. Something more similar to the

Ruby 1.9.2 and Rails 3 cannot open rails console

丶灬走出姿态 提交于 2020-01-18 21:34:31
问题 [gkaykck@main myApplication]$ rails console /usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError) from /usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `require' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `<top (required)>' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib

Ruby 1.9.2 and Rails 3 cannot open rails console

﹥>﹥吖頭↗ 提交于 2020-01-18 21:34:12
问题 [gkaykck@main myApplication]$ rails console /usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError) from /usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `require' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `<top (required)>' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib

Best way to add “current” class to nav in Rails 3

与世无争的帅哥 提交于 2020-01-18 11:15:58
问题 I have some static pages in a navigation menu. I want to add a class like "current" to the item which is currently displaying. The way I am doing so is to add tons of helper methods (each for one item) to check the controller and action. def current_root_class 'class="current"' if controller_name == "homepage" && action_name == "index" end <ul> <li <%= current_root_class %>><%= link_to "Home", root_path %> Is there any better way to do so!? My current way is so stupid...... 回答1: Not truly an

Best way to add “current” class to nav in Rails 3

做~自己de王妃 提交于 2020-01-18 11:14:33
问题 I have some static pages in a navigation menu. I want to add a class like "current" to the item which is currently displaying. The way I am doing so is to add tons of helper methods (each for one item) to check the controller and action. def current_root_class 'class="current"' if controller_name == "homepage" && action_name == "index" end <ul> <li <%= current_root_class %>><%= link_to "Home", root_path %> Is there any better way to do so!? My current way is so stupid...... 回答1: Not truly an

Best way to add “current” class to nav in Rails 3

荒凉一梦 提交于 2020-01-18 11:13:27
问题 I have some static pages in a navigation menu. I want to add a class like "current" to the item which is currently displaying. The way I am doing so is to add tons of helper methods (each for one item) to check the controller and action. def current_root_class 'class="current"' if controller_name == "homepage" && action_name == "index" end <ul> <li <%= current_root_class %>><%= link_to "Home", root_path %> Is there any better way to do so!? My current way is so stupid...... 回答1: Not truly an

Rails transaction doesn't input correct data

痞子三分冷 提交于 2020-01-17 12:34:07
问题 The Signup form in my app allows users to create an account - it also creates their user record and an accounts_users (has_many :through) record. Once they click submit, I am calling the 'setup_account' method to input several default values for the user's new account. With that said, the method is close to working but is inputting incorrect values for the three records where I manually assign values (i.e. :user_id => @user or :account_id => @account). The incorrect value for account_id and

Rails transaction doesn't input correct data

让人想犯罪 __ 提交于 2020-01-17 12:33:24
问题 The Signup form in my app allows users to create an account - it also creates their user record and an accounts_users (has_many :through) record. Once they click submit, I am calling the 'setup_account' method to input several default values for the user's new account. With that said, the method is close to working but is inputting incorrect values for the three records where I manually assign values (i.e. :user_id => @user or :account_id => @account). The incorrect value for account_id and

UnknownAttributeError in Controller

ⅰ亾dé卋堺 提交于 2020-01-17 08:08:09
问题 With the help of @Sasha i created an nested form for treatments in patients: Now i get this error: UnknownAttributeError in PatientsController#update unknown attribute: treatment My patients update controller actually looks like this: def update @patient = Patient.find(params[:id]) respond_to do |format| if @patient.update_attributes(params[:patient]) format.html { redirect_to @patient, notice: 'Patient was successfully updated.' } format.json { head :no_content } else format.html { render