Reputation: 107
I just added a new "imgurl" column by the following migration:
rails generate migration add_imgurl_to_users imgurl:string
and when I check my rails console, this is what I see for user 1:
irb(main):002:0> a = User.find_by(id: 1)
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
=> #<User id: 1, name: "iscprz", email: "[email protected]", created_at: "2014-11-04 02:18:15", updated_at: "2014-11-04 02:45:33", password_digest: "$2a$10$UvHGZPAxQdCrsbOEyJeLPOuzXm7aJLYWJNKRnkJ5NkA...", imgurl: nil>
Whenever I make a new user, I get to my new.html.erb file inside the 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) do |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 my account", class: "btn btn-primary" %>
<% end %>
</div>
</div>
<%= link_to 'Back', users_path %>
but at the screen, I enter text into the imgurl field and it doesn't save it to the database upon submitting the form...(the imgurl field is always nil after I check in rails console).
What step have I forgotten to take after having created the new imgurl column?
Upvotes: 0
Views: 21
Reputation: 23939
Your params.require(:user).permit(:name, :email, ...)
in your controller?
Upvotes: 1