Also wanted to know while using update_attribute method, how to
actually test that the attribute has effectively been updated ? ( need
to test to trigger appropriate popup message )
just wanted to know how to actually test returned value from sql
statement like :
@alreadyused = Promotioncodes.find_by_sql [ "select alreadyused from
promotioncodes where id = ?", @codeid ]
I would like to check whether @alreadyused has value 1 or 0
count_by_sql
next, what's wrong with
PromotionCode.find_by_id(@codeid).alreadyused
?
I would guess what's wrong with it is your model names don't follow Rails conventions, so you have not yet tuned your ActiveRecord calls to match them.