Where are all my fields?

I am confused as to why I am not able to view all the fields of a
model I created when I try to create a new object. I checked my DB and
they are all there, how ever when I click the “new” link to create a
new object, some of the fields are missing. I edited the _form by hand
to add the missing fields, but “show” and “list” doesn’t list the
items that were originally missing from create. I am new to rails and
still trying to understand what is going on. Any help/insight would be
greatly appreciated. Thanks
-J

On Jan 6, 2008 4:53 PM, jvazquez [email protected] wrote:

I am confused as to why I am not able to view all the fields of a
model I created when I try to create a new object. I checked my DB and
they are all there, how ever when I click the “new” link to create a
new object, some of the fields are missing. I edited the _form by hand
to add the missing fields, but “show” and “list” doesn’t list the
items that were originally missing from create. I am new to rails and
still trying to understand what is going on. Any help/insight would be
greatly appreciated. Thanks

I’m guessing you used scaffolding, and then edited the migration (if
not, then just ignore my post).
Something like:

ruby script/generate scaffold product name:string price:decimal
[a bunch of static files are generated, among others
db/migrate/001_create_products.rb]

if, before you run the migration, you edit
db/migrate/001_create_products.rb and add, let’s say, a description
column, and then rake db:migrate, your table will include this new
column, but your views are still in the same state they were in when
you did the scaffolding, only showing the name and price fields you
told the scaffold about.

The default scaffolding is a one time operation to get you started on
a resource. Once the files are there, you have to edit them yourself.
(Or run the scaffold again, or use one of the plugins for dynamic
scaffolding etc.)

  • Martin

I did in fact use scaffolding, but I ran it after I generated my model
and added all the columns I wanted. I just can’t wrap my head around
what is wrong.
How can I edit the show.rhtml to display the things that are missing?
My understanding is that the following code(contained in show.rhtml)
would display all columns contained in my DB

<% for column in Housing.content_columns %>

<%= column.human_name %>: <%=h @housing.send(column.name) %>

<% end %>

controller contains
def show
@housing = Housing.find(params[:id])
end

I think I have discovered what might be the problem. It appears that
“content_columns” Returns an array of column objects where the primary
id, all columns ending in “_id” or “_count”, and columns used for
single table inheritance have been removed. It turns out that my
missing fields refer to columns ending in “id” and “count”. There is a
similar “columns” method that should show me what I need.
thanks
-Juan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs