I’m a compete Rails n00b and trying to understand how this thing works
so any help is greatly appreciated.
I created a table using migrations, so far so good. My view shows the
list and I can add new records. Now I forgot one column so I added it by
creation a new migration file with an add_column. Raked this migration
and checked the database, it’s there.
When I go to my listing web-page the listing is updated BUT, when I
click the New link on this page the input forms still show the old
structure and my newly added column doesn’t show up.
I tried to do this without migrations (manually in the database),
restarted Apache, restarted MySQL, migrated to version 0 and back and it
still doesn’t show up.
I’m a compete Rails n00b and trying to understand how this thing works
so any help is greatly appreciated.
I created a table using migrations, so far so good. My view shows the
list and I can add new records. Now I forgot one column so I added it by
creation a new migration file with an add_column. Raked this migration
and checked the database, it’s there.
When I go to my listing web-page the listing is updated BUT, when I
click the New link on this page the input forms still show the old
structure and my newly added column doesn’t show up.
Could show your view code, and your controller code?
<% form_tag :action => ‘create’ do %>
<%= render :partial => ‘form’ %>
<%= submit_tag “Create” %>
<% end %>
<%= link_to ‘Back’, :action => ‘list’ %>
Many thanks!
Well those scaffold just get you started. They are not really designed
to continually reflect on your database structure. After you generate
them you are expected to maintain them yourself. This is not a
limitation, it’s designed to make you move past that featureless ugly
scaffold and into wherever you want to go.
So to add that new field to your forms, you need to add the view code
for it. As you can see in your new.rhtml file, it render the partial
called “form”. Look in that same folder for a file named “_form.rhtml”
because that is what is being rendered.
Copy one of the existing form field declarations and change the field
name its accessing.
Thanks, have been looking for this for days and never got to the
_form.rhtml. Doh! I can see it new, off course you don’t need the
duplicate code in the edit.rhtml and new.rhtml so this makes sense.
Thanks Alex, this hold me back from going on, thanks to you I found the
motivation again.