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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 6, 2008 4:53 PM, jvazquez <Juanvazquez-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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. ThanksI''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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 %> <p> <b><%= column.human_name %>:</b> <%=h @housing.send(column.name) %> </p> <% end %> controller contains def show @housing = Housing.find(params[:id]) end On Jan 6, 10:35 am, "Martin Svalin" <martin.sva...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 6, 2008 4:53 PM, jvazquez <Juanvazq...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Jan 6, 10:35 am, "Martin Svalin" <martin.sva...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 6, 2008 4:53 PM,jvazquez<Juanvazq...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---