Brian A.
2008-Dec-19 20:30 UTC
Noob - added a column via migration but get error on insert
Hello! I''m very new to ruby and ruby on rails. I''m following a tutorial found here: www.javapassion.com/handsonlabs/rails_activerecord/ I''m running NetBeans as an IDE, with jruby, rails and MySQL. Here is the basic rundown of what I have done 1) Created db via Rake 2) Created table with 3 columns via Migration (user name:string hobby:string age:integer) 3) Inserted 3 user records via Rails Console 4) Added additional column via Migration (AddEmailField email:string) (Inside the migration rb -> "add_column :users, :email, :string" 5) This is where things go poorly, I try to add a new user with the email but get an error. Here is what I enter via Rails Console user = User.new(:name => "TommyJones", :hobby => "tennis", :age => 138, :email => "emaila-hqliFBSW7YMS+FvcfC7Uqw@public.gmane.org") And I get the following error: -------------------------------------------------------------- NoMethodError: undefined method `email='' for #<User:0x751932> from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:251:in `method_missing'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2361:in `attributes='' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2360:in `each'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2360:in `attributes='' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2130:in `initialize'' from (irb):23:in `binding'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/1.8/irb.rb:150:in `eval_input'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/1.8/irb.rb:259:in `signal_status'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/1.8/irb.rb:147:in `eval_input'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/1.8/irb.rb:146:in `eval_input'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/1.8/irb.rb:70:in `start'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/1.8/irb.rb:69:in `catch'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4/lib/ruby/1.8/irb.rb:69:in `start'' from C:/Program Files/NetBeans 6.5 RC2/ruby2/jruby-1.1.4\bin\jirb:19 ------------------------------------------------------------- Being so new to this I cannot figure out why it won''t allow me to enter a user using all the fields? If I do the same entry without the email information to insert it still works. Thanks in advance! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2008-Dec-19 20:38 UTC
Re: Noob - added a column via migration but get error on insert
On Fri, Dec 19, 2008 at 12:30 PM, Brian A. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 1) Created db via Rake > 2) Created table with 3 columns via Migration (user name:string > hobby:string age:integer) > 3) Inserted 3 user records via Rails Console > 4) Added additional column via Migration (AddEmailField email:string) > (Inside the migration rb -> "add_column :users, :email, :string"There should be a step 4a) here -- rake db:migrate Did you do that? If so, can you confirm that the table was altered?> 5) This is where things go poorly, I try to add a new user with the > email but get an error. Here is what I enter via Rails Console > user = User.new(:name => "TommyJones", :hobby => "tennis", :age => 138, > :email => "emaila-hqliFBSW7YMS+FvcfC7Uqw@public.gmane.org")And did you restart the console after running the migration? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Brian A.
2008-Dec-19 20:44 UTC
Re: Noob - added a column via migration but get error on insert
Hassan Schroeder wrote:> On Fri, Dec 19, 2008 at 12:30 PM, Brian A. > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > There should be a step 4a) here -- rake db:migrate > > Did you do that? If so, can you confirm that the table was altered? > > And did you restart the console after running the migration? >Hello! Yes I did perform the migrations and can see the new ''email'' column in the database. I did not restart the console however. Does Rails need to be restarted to learn about changes like this? Thanks again. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2008-Dec-19 20:47 UTC
Re: Noob - added a column via migration but get error on insert
On Fri, Dec 19, 2008 at 12:44 PM, Brian A. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:>> And did you restart the console after running the migration?> Yes I did perform the migrations and can see the new ''email'' column in > the database. I did not restart the console however. Does Rails need > to be restarted to learn about changes like this?I believe so -- but it should be easy enough to find out, eh? :-) Let me know if that doesn''t fix the problem. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Brian A.
2008-Dec-19 20:51 UTC
Re: Noob - added a column via migration but get error on insert
Hassan Schroeder wrote:> > I believe so -- but it should be easy enough to find out, eh? :-) > > Let me know if that doesn''t fix the problem. >Thanks! That did the trick. So anytime I make a DB modification and am working via the console I need to restart it so it will become aware of the changes. Very interesting. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marnen Laibow-Koser
2008-Dec-20 05:29 UTC
Re: Noob - added a column via migration but get error on insert
On Dec 19, 3:51 pm, "Brian A." <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thanks! That did the trick. So anytime I make a DB modification and am > working via the console I need to restart it so it will become aware of > the changes. Very interesting.I believe you can also type app.reload! in the console. Also, as you go forward with Rails, you might want to consider giving jEdit a try as an IDE. It''s powerful, but much easier to work with for Rails than are "heavier" programs like NetBeans or Eclipse. See http://marnen.livejournal.com/23723.html for more info on configuring jEdit. Best, -- Marnen Laibow-Koser marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org http://www.marnen.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marnen Laibow-Koser
2008-Dec-22 04:39 UTC
Re: Noob - added a column via migration but get error on insert
On Dec 20, 12:29 am, Marnen Laibow-Koser <mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org> wrote:> On Dec 19, 3:51 pm, "Brian A." <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Thanks! That did the trick. So anytime I make a DB modification and am > > working via the console I need to restart it so it will become aware of > > the changes. Very interesting. > > I believe you can also type app.reload! in the console.I goofed. Just type reload! (without the app. part). Sorry about that. Best, -- Marnen Laibow-Koser marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org http://www.marnen.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---