Reputation: 715
i should check whether there is some values based on this condition. if there is some, then i should do one action or else do a different action.
i work on rails, mysql and xp
this is not working @test.nil?
suggest me a alternate way
@test=Model.find(:all,:conditions=>"id=@someid")
thanks in advance
Upvotes: 0
Views: 1039
Reputation: 115362
@test.nil?
should work fine. It's probably not working because your find method is wrong. Try this instead:
@test = Model.find_by_id(@someid)
An alternative syntax is:
@test = Mode.find(@someid)
—Which will raise a RecordNotFound
exception if the record doesn't exist.
Upvotes: 7