Querying using Ruby on Rails

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



In Rails you rarely need to use find_by_sql.

You can easily do things like this with

Why don’t read a bit more about ActiveRecord and Rails in general?


On 5/11/07, Venugopal [email protected] wrote:


Posted via http://www.ruby-forum.com/.

Best regards,
Yuri L.


Author.find(:all, :conditions => {:username => @username })
replace :all, for :first if needed.

Zach I.
→ Blog — http://www.zachinglis.com
→ Company — http://www.lt3media.com
→ Portfolio — http://portfolio.zachinglis.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs