lundi 30 novembre 2015

How do I get a value from query and add the value by 1 on Rails

I really appreciate any respond for this simple question.

test = Model.find_by_sql("SELECT number FROM tbl_one LIMIT 1").each do |a| p = a('number') puts p end

Look, I mean, after store a value to 'p', how do I add the 'p' value by 1. Hide Copy Code

puts p + 1

I tried it but doesn't work. Based on what I saw, the 'p' doesn't really store the value, but I don't really sure. Anyway, I'm new on Ruby and Rails

Any solution? Thanks.

Note: I asked this question in ^cp also. Just to make sure quick responds. Thanks.




Aucun commentaire:

Enregistrer un commentaire