After migration, how to see new columns?

New to rails so please bear with me. I used migrations to add a column
to an existing table. The new column is added to the database
successfully. However when I go to ‘list’ the items, the new column
isn’t displayed. When I go to ‘create’ a new item, the new column is
displayed and when entered, saves to the new database column correctly.
How can I get the column to ‘list’ as well?

Have you tried restarting the server?

Adding a column in a migration won’t make rails add the necessary view
code to show it. That’s up to you.

Rein
http://reinh.com

On Sep 4, 12:12 pm, Marshall T. <rails-mailing-l…@andreas-

Thanks for your reply. What’s interesting is that I did change the
_form view and when I go to create a new item, the new column does show
and save to the database. However, list and edit don’t show the new
column. They don’t seem to have separate views, all calling on the same
_form.

Any ideas?

Thanks!

Rein H. wrote:

Adding a column in a migration won’t make rails add the necessary view
code to show it. That’s up to you.

Rein
http://reinh.com

On Sep 4, 12:12 pm, Marshall T. <rails-mailing-l…@andreas-

On 9/4/07, Marshall T. [email protected] wrote:

Thanks for your reply. What’s interesting is that I did change the
_form view and when I go to create a new item, the new column does show
and save to the database. However, list and edit don’t show the new
column. They don’t seem to have separate views, all calling on the same
_form.

are you absolutely sure that create and edit are both calling render
:partial => ‘form’ to display the new/edit form?

And list should be a different view and usually doesn’t render the
form that create and edit use, since it’ll be a list of your items.
To include your new colum in the list view, just do something like

<%= @object.my_new_column %>

Adam

Thanks Adam. I’m attaching a document with screenshots of my situation
since I still can’t get it to work properly. Again, apologize since I’m
new to Rails but being able to migrate a database to a new version and
having the new columns show up in my views is critical for progress :).
Appreciate any help you all may be able to provide.

Adam C. wrote:

On 9/4/07, Marshall T. [email protected] wrote:

Thanks for your reply. What’s interesting is that I did change the
_form view and when I go to create a new item, the new column does show
and save to the database. However, list and edit don’t show the new
column. They don’t seem to have separate views, all calling on the same
_form.

are you absolutely sure that create and edit are both calling render
:partial => ‘form’ to display the new/edit form?

And list should be a different view and usually doesn’t render the
form that create and edit use, since it’ll be a list of your items.
To include your new colum in the list view, just do something like

<%= @object.my_new_column %>

Adam

On 9/4/07, Marshall T. [email protected] wrote:

Thanks Adam. I’m attaching a document with screenshots of my situation
since I still can’t get it to work properly. Again, apologize since I’m
new to Rails but being able to migrate a database to a new version and
having the new columns show up in my views is critical for progress :).
Appreciate any help you all may be able to provide.

Are you absolutely sure you restarted your webserver process?
Everything looks good to me. Keep in mind that Class.content_columns
won’t retrieve every column in your database. For example, foreign
key attributes will not be retrieved (are project and vendor actually
project_id and vendor_id ?), and it seems that columns with the word
‘count’ in them won’t be returned either. In any case, an easy way to
solve this is to start replacing the scaffolding code with real code
(scaffolding is really just meant as a starting point anyways).

So instead of using:

<% for column in Item.content_columns %> <% end %> ....
<%= column.human_name %>

you can do the following:

controller.rb:
@items = Item.find(:all)

in your view.rhtml:

... <% for item in @items %> <% end %>
Project Vendor SKU Name
<%= item.project %></t

Hope this helps

Adam