Hi I''m a noob to RoR. I have everything setup but can''t figure out to get the list display as I would like. I''m sure this is very simple stuff. I just haven''t figured it out yet :( I hope someone can point me in the right direction :) I have a mysql table "websites". In it I have the following columns - Name, Url, Banner, Description I created "ruby script/generate controller website" (& the model too) and inserted model :website scaffold :website have not changed the website_controller.rb (well that''s not strictly true I tried but couldn''t get it to work so reverted back). Website/list.rhtml is also the default scaffold build. So I get a nice view of the content of the websites table, however I want to format this output into something useful. Something like a looping version of this. <a href="Url"><img src="Banner" alt"Name" /><a/> <p>Description</p> It seems the default view grabs everything in one block where as I want to grab and use the individual columns. I don''t know enough of the terminology to to a search to find out how to do such a thing and most of the tutorials I have gone through seem to display the default scaffold views. If someone can give me some pointers or even a link to a relevant tutorial on how to set up such a thing I would be very grateful. Cheers -- 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 -~----------~----~----~----~------~----~------~--~---
Your controller: def list @websites = Website.find(:all) end Your view (list.html.erb): <% for website in @websites %> ...stuff for each website here, referencing the column values as website.column. <% end %> On Dec 22, 2007 10:35 PM, Bill Griffin <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi > > I''m a noob to RoR. I have everything setup but can''t figure out to get > the list display as I would like. I''m sure this is very simple stuff. I > just haven''t figured it out yet :( > > I hope someone can point me in the right direction :) > > I have a mysql table "websites". > > In it I have the following columns - Name, Url, Banner, Description > > I created "ruby script/generate controller website" (& the model too) > and inserted > > model :website > scaffold :website > > have not changed the website_controller.rb (well that''s not strictly > true I tried but couldn''t get it to work so reverted back). > > Website/list.rhtml is also the default scaffold build. > > So I get a nice view of the content of the websites table, however I > want to format this output into something useful. > > Something like a looping version of this. > > <a href="Url"><img src="Banner" alt"Name" /><a/> > > <p>Description</p> > > It seems the default view grabs everything in one block where as I want > to grab and use the individual columns. > > I don''t know enough of the terminology to to a search to find out how to > do such a thing and most of the tutorials I have gone through seem to > display the default scaffold views. > > If someone can give me some pointers or even a link to a relevant > tutorial on how to set up such a thing I would be very grateful. > > Cheers > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nice one - thanks Ryan. I knew it was simple. There is no stopping me now :) One more question. What is the ".erb" in "(list.html.erb)" below? Cheers Ryan Bigg wrote:> Your controller: > > def list > @websites = Website.find(:all) > end > > > Your view (list.html.erb): > > <% for website in @websites %> > ...stuff for each website here, referencing the column values as > website.column. > <% end %> > > On Dec 22, 2007 10:35 PM, Bill Griffin > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >> >> >> >> Cheers >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > Ryan Bigg > http://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.-- 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 -~----------~----~----~----~------~----~------~--~---
Oh that''s for Rails 2.0, if you''re using it. instead of it being called list.rhtml it''s now list.html.erb. This is so you can use different formats with maintaining an easy to follow naming schema. Nothing you''d have to worry about. Yet. On Dec 22, 2007 11:00 PM, Bill Griffin <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Nice one - thanks Ryan. I knew it was simple. There is no stopping me > now :) > > One more question. What is the ".erb" in "(list.html.erb)" below? > > Cheers > > Ryan Bigg wrote: > > Your controller: > > > > def list > > @websites = Website.find(:all) > > end > > > > > > Your view (list.html.erb): > > > > <% for website in @websites %> > > ...stuff for each website here, referencing the column values as > > website.column. > > <% end %> > > > > On Dec 22, 2007 10:35 PM, Bill Griffin > > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > >> > >> > >> > >> Cheers > >> -- > >> Posted via http://www.ruby-forum.com/. > >> > >> > > >> > > > > > > -- > > Ryan Bigg > > http://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email. > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---