Forum: Ruby on Rails Querying using Ruby on Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4edee2a9acd121ba6985bb595f33130a?d=identicon&s=25 Venugopal (Guest)
on 2007-05-11 09:21
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
8d1e089fd6a6703f5f13dbee271aa77c?d=identicon&s=25 Yuri Leikind (Guest)
on 2007-05-11 09:56
(Received via mailing list)
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@andreas-s.net> wrote:
>
> Venugopal
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--
Best regards,
Yuri Leikind
Df4978da52459529e539da4c995918cb?d=identicon&s=25 Zach Inglis // LT3media (Guest)
on 2007-05-11 10:24
(Received via mailing list)
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
This topic is locked and can not be replied to.