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@asdfgmail.com")
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@asdfgmail.com")
And did you restart the console after running the migration?
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.
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
Rails IDE: jEdit wins? - Marnen Laibow-Koser's Journal — LiveJournal for more info on configuring
jEdit.