Re: [Rails] find_by

2010-03-16 Thread Surender Pareek
On Mon, Mar 15, 2010 at 4:17 PM, M I R wrote: > hi, > I have to retrieve data from table with two conditions using a actully > the following query > > select * from abc where id=1 and type = 'a' > > how will i do if: > > find_by_id(id) > how will i use for multiple conditions > > -- > You rec

Re: [Rails] find_by

2010-03-15 Thread Michael Pavling
On 15 March 2010 10:47, M I R wrote: > select * from abc where id=1 and type = 'a' > > how will i do if: > > find_by_id(id) > how will i use for multiple conditions Model.all(:conditions => ["id = ? AND type = ?", id, type]) http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002263

[Rails] find_by

2010-03-15 Thread M I R
hi, I have to retrieve data from table with two conditions using a actully the following query select * from abc where id=1 and type = 'a' how will i do if: find_by_id(id) > how will i use for multiple conditions -- You received this message because you are subscribed to the Google Groups

[Rails] Find_by

2010-02-01 Thread RubyonRails_newbie
Hi All, I'm looking to improve finding friends on my site, by adding a ''suggestion'' page/area. BAsically, a query should be run against a logged in user and find other people from the same town/location. Or that share a similar hobby etc. I have a controller and an index page i want to update

[Rails] find_by should return a default

2009-06-23 Thread Jens --
Hi, I am puzzlin for quite a while on this. I use find_by methods to retieve AR objects. In some cases find_by will return nil if there is no match. However I would like to have find_by return a default object instead. Is there a way to overload that particular find_by method? Or whats the best

[Rails] find_by...

2009-04-29 Thread slava
Hello, I am trying to construct a lookup based on params submited. possible urls.. /gadgets?product_id=1 /gadgets?product_id=1&product_group_id=2 /gadgets?product_location_id=5 /gadgets?product_id=1&product_location=5 ... How do I write a universal lookup method ? Gadget.find_by_product_id Gadge