hi, i want to fetch the data''s from the datanase. it display in combo box . but i am very new to ROR. so i don''t know what are all the steps to do this. like where i have to put in controllter or in rhtml file. Can any one tell step by step process, if u can. please its very urgent. my database name is : panles it contain - id,name. combo box i want to display - panel name. controller name is - home rthml file is - index.rhtml right now i have done index.rhtml only, rest i don''t know how to do <%@panles = panel.find(:all, :panel => "name") collection_select(:panel, :name, @panels, :id, :name) %> but it shows the error. please help me asap -- 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 -~----------~----~----~----~------~----~------~--~---
Steve Bartholomew
2007-Jan-30 10:31 UTC
Re: i want to fetch the data''s from the datanase. it display in
> <%> @panles = panel.find(:all, :panel => "name") > collection_select(:panel, :name, @panels, :id, :name) > %>There are a number of problems with this code. The first thing is that <%= %> is effectively saying ''output everything within these brackets'' - you have 2 lines of code so you''re going to get issues. The second problem is that the line ''@panels = ...'' should be in your controller action: in your controller: def index @panels = Panel.find(:all); end in your view: <%= collection_select(''panel'', ''name'', @panels, :id, :name) %> For future reference, you will generally get better response if you post the actual error message you are receiving. I''d also recommend that you pick up one of the many books and tutorials that are available to give you a solid grounding in rails. Steve --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hi, Thanks a lot. i got it. and can u tell how i display using list box using the same table. please. Stephen Bartholomew wrote:>> <%>> @panles = panel.find(:all, :panel => "name") >> collection_select(:panel, :name, @panels, :id, :name) >> %> > There are a number of problems with this code. The first thing is > that <%= %> is effectively saying ''output everything within these > brackets'' - you have 2 lines of code so you''re going to get issues. > > The second problem is that the line ''@panels = ...'' should be in your > controller action: > > in your controller: > def index > @panels = Panel.find(:all); > end > > in your view: > <%= collection_select(''panel'', ''name'', @panels, :id, :name) %> > > For future reference, you will generally get better response if you > post the actual error message you are receiving. I''d also recommend > that you pick up one of the many books and tutorials that are > available to give you a solid grounding in rails. > > Steve-- 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 -~----------~----~----~----~------~----~------~--~---