I think what you might have missed is that rails generate only creates a migration file --- it doesn't actually put the instructions to do the migration into them migration file. It also doesn't' make any changes to your Model or View files (as you said).
look in db/migrate/ for a file that recently got created (it will have a timestamp like 20140902..... and part of its name will be "add_column_to_table") If I'm right, when you open that file, you'll see empty up and down methods. You'll want to add to the up method add_column :users, :filename, :string and to the down method remove_column :users, :filename (I just made up "users" since you didn't specify what model this is) Once you do that, run rake db:migrate (be sure to do rake db:migrate RAILS_ENV=test for your test environment) and also stop & restart your webserver too! -Jason On Aug 31, 2014, at 1:18 PM, Balamurali Krishna <[email protected]> wrote: > I am trying to learn Ruby on Rails, so this may be a pretty basic > question. > > I have added new columns to an existing table using > 'rails generate migration add_column_to_table' command. > > I don't see any change in model & view due to this. > > So, I changed the all the views (like _form.html.erb & index.html.erb) > to include a new form element like: > <%= f.label :filename %><br> > <%= f.text_field :filename %> > > where :filename was the new column. > > When I run the rails, while the new column comes on UI, it doesn't get > saved into db. I think the binding between View and Model is missing. > > Is there a way to add a new column in the table to all layers > (view/controller/model etc) apart from the db. > > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/080c37def7708ef100f8e76a87b9abc1%40ruby-forum.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2E6E6EC0-348D-4B11-A390-85E535C61D63%40datatravels.com. For more options, visit https://groups.google.com/d/optout.

