ruby - Trouble accessing column value rails console -
i'm trying access integer stored in column called totalvotes in uservotes table maintain getting no method error
i have been trying debug console:
1.9.3-p327 :006 > uservote = uservote.where("soundcloud_id = 68061927") uservote load (0.2ms) select "user_votes".* "user_votes" (soundcloud_id = 68061927) => [#<uservote id: 5, user_id: "1", party_profile_id: "1", soundcloud_id: "68061927", totalvotes: 0, created_at: "2013-02-19 04:57:58", updated_at: "2013-02-19 04:57:58">]
good far...
1.9.3-p327 :007 > uservote.totalvotes nomethoderror: undefined method `totalvotes' #<activerecord::relation:0x007febb49ab350>
then breaks , i'm not sure why. best way me access totalvotes value?
your issue you're calling .totalvotes
ar relation. phone call .first
first should have no problem.
>> uservote = uservote.where("soundcloud_id = 68061927").first >> uservote.totalvotes
ruby-on-rails ruby rails-activerecord rails-console
No comments:
Post a Comment