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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Have you tried restarting the server? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 Taplits <rails-mailing-l...@andreas- s.net> wrote:> 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? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 Henrichs 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 Taplits <rails-mailing-l...@andreas--- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 9/4/07, Marshall Taplits <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 Cohen wrote:> On 9/4/07, Marshall Taplits <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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 %> > > AdamAttachments: http://www.ruby-forum.com/attachment/227/Document.zip -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 9/4/07, Marshall Taplits <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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: <table> <tr> <% for column in Item.content_columns %> <th><%= column.human_name %></th> <% end %> </tr> .... </table> you can do the following: controller.rb: @items = Item.find(:all) in your view.rhtml: <table> <thead> <tr><th>Project</th><th>Vendor</th><th>SKU</th><th>Name</th>...</tr> </thead> <tbody> <% for item in @items %> <tr> <td><%= item.project %></t </tr> <% end %> </tbody> </table> Hope this helps Adam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---