Wednesday, 15 January 2014

ruby on rails - Unable to edit a table element after having just added column -



ruby on rails - Unable to edit a table element after having just added column -

i added new "imgurl" column next migration:

rails generate migration add_imgurl_to_users imgurl:string

and when check rails console, see user 1:

irb(main):002:0> = user.find_by(id: 1) user load (0.3ms) select "users".* "users" "users"."id" = 1 limit 1 => #<user id: 1, name: "iscprz", email: "fakeemail2@gmail.com", created_at: "2014-11-04 02:18:15", updated_at: "2014-11-04 02:45:33", password_digest: "$2a$10$uvhgzpaxqdcrsboeyjelpouzxm7ajlywjnkrnkj5nka...", imgurl: nil>

whenever create new user, new.html.erb file within users view:

<h1>new user</h1> <h1>sign up</h1> <div class="row"> <div class="col-md-6 col-md-offset-3"> <%= form_for(@user) |f| %> <%= f.label :name %> <%= f.text_field :name %> </br> <%= f.label :email %> <%= f.text_field :email %></br> <%= f.label :password %> <%= f.password_field :password %> </br> <%= f.label :password_confirmation, "confirmation" %> <%= f.password_field :password_confirmation %></br> <%= f.label :imgurl, "background image url" %> <%= f.text_field :imgurl %> </br> <%= f.submit "create account", class: "btn btn-primary" %> <% end %> </div> </div> <%= link_to 'back', users_path %>

but @ screen, come in text imgurl field , doesn't save database upon submitting form...(the imgurl field nil after check in rails console).

what step have forgotten take after having created new imgurl column?

your params.require(:user).permit(:name, :email, ...) in controller?

ruby-on-rails ruby database migration

No comments:

Post a Comment