I am using rvm on the ubuntu. I am following the rails tutorial from Lynda.com I was on the section of working in the rails console when i got the following errors :- I gave the command rails console nitin@nitin-vaio:~/Nitin/Sites/app$ rails console Loading development environment (Rails 3.2.1) 1.9.2p290 :001 > subject=Subject.new => #<Subject id: nil, subject_name: nil, position: nil, visible: false, created_at: nil, updated_at: nil> 1.9.2p290 :002 > subject.new_record? => true 1.9.2p290 :003 > subject.name = "History" NoMethodError: undefined method `name='' for #<Subject:0x8ab6e9c> from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/activemodel-3.2.1/lib/active_model/attribute_methods.rb:407:in `method_missing'' from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/attribute_methods.rb:126:in `method_missing'' from (irb):3 from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/railties-3.2.1/lib/rails/commands/console.rb:47:in `start'' from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/railties-3.2.1/lib/rails/commands/console.rb:8:in `start'' from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:41:in `<top (required)>'' from script/rails:6:in `require'' from script/rails:6:in `<main>'' 1.9.2p290 :004 > subject.name = "History" NoMethodError: undefined method `name='' for #<Subject:0x8ab6e9c> from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/activemodel-3.2.1/lib/active_model/attribute_methods.rb:407:in `method_missing'' from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/attribute_methods.rb:126:in `method_missing'' from (irb):4 from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/railties-3.2.1/lib/rails/commands/console.rb:47:in `start'' from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/railties-3.2.1/lib/rails/commands/console.rb:8:in `start'' from /home/nitin/Nitin/Sites/app/mysql2/ruby/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:41:in `<top (required)>'' from script/rails:6:in `require'' from script/rails:6:in `<main>'' When I tried to create a subject name I got the above errors. I couldn''t find the solution on google. Please help me if anyone has encountered such an error and solved it. Attachments: http://www.ruby-forum.com/attachment/7053/Screenshot_at_2012-02-13_14_11_38.png -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mon, Feb 13, 2012 at 9:43 AM, Nitin A. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am using rvm on the ubuntu. I am following the rails tutorial from > Lynda.com > I was on the section of working in the rails console when i got the > following errors :- > > I gave the command rails console > > > nitin@nitin-vaio:~/Nitin/Sites/app$ rails console > > Loading development environment (Rails 3.2.1) > > 1.9.2p290 :001 > subject=Subject.new > => #<Subject id: nil, subject_name: nil, position: nil, visible: false, > created_at: nil, updated_at: nil> >Your variable name is "subject_name"> > 1.9.2p290 :002 > subject.new_record? > => true > > 1.9.2p290 :003 > subject.name = "History" > NoMethodError: undefined method `name='' for #<Subject:0x8ab6e9c> > from >Here, you want to use a variable with name "name". Could you try:> subject.subject_name = "History"You could also change the name of the column with a migration. HTH, Peter -- *** Available for a new project *** Peter Vandenabeele http://twitter.com/peter_v http://rails.vandenabeele.com http://coderwall.com/peter_v -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.