Hi Everyone.... I''need to query using Ruby on rails...dynamically rather than hard coding the statement like: select* from authors where name="Hello"; i need to get the value of the name from a text box in the earlier page and transfer the value to the next page and have a statement like select * from author where name=" #{@username}" similar to this so tat my search could be dynamic .... i''ve tried with find_by_sql... but don''t know which file i need to add the code... Thanks & Regards Venugopal -- 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 -~----------~----~----~----~------~----~------~--~---
Hey, In Rails you rarely need to use find_by_sql. You can easily do things like this with Author.find_by_name(username) Why don''t read a bit more about ActiveRecord and Rails in general? Cheers, Yuri On 5/11/07, Venugopal <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi Everyone.... > > I''need to query using Ruby on rails...dynamically rather than hard > coding the > statement like: > select* from authors where name="Hello"; > > i need to get the value of the name from a text box in the earlier page > and transfer the value to the next page and have a statement like > > select * from author where name=" #{@username}" > > similar to this so tat my search could be dynamic .... > > i''ve tried with find_by_sql... but don''t know which file i need to add > the code... > > > Thanks & Regards > > Venugopal > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Best regards, Yuri Leikind --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Or... Author.find(:all, :conditions => {:username => @username }) replace :all, for :first if needed. Zach Inglis → Blog — http://www.zachinglis.com → Company — http://www.lt3media.com → Portfolio — http://portfolio.zachinglis.com On May 11, 2007, at 2:55 AM, Yuri Leikind wrote:> > Hey, > > In Rails you rarely need to use find_by_sql. > > You can easily do things like this with > Author.find_by_name(username) > > Why don''t read a bit more about ActiveRecord and Rails in general? > > Cheers, > Yuri > > > > On 5/11/07, Venugopal <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> Hi Everyone.... >> >> I''need to query using Ruby on rails...dynamically rather than hard >> coding the >> statement like: >> select* from authors where name="Hello"; >> >> i need to get the value of the name from a text box in the earlier >> page >> and transfer the value to the next page and have a statement like >> >> select * from author where name=" #{@username}" >> >> similar to this so tat my search could be dynamic .... >> >> i''ve tried with find_by_sql... but don''t know which file i need to >> add >> the code... >> >> >> Thanks & Regards >> >> Venugopal >> >> -- >> Posted via http://www.ruby-forum.com/. >> >>> >> > > > -- > Best regards, > Yuri Leikind > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---