3

I am trying to do this using SQL in Ruby:

SELECT number*2 FROM dictionary;

I can use .select(:number) to get the number columns "as is", but I have no idea how to return them modified. I tried this (which obviously didn't work):

current_table.select(:number*2)
Matt
  • 14,906
  • 27
  • 99
  • 149
A.V. Arno
  • 513
  • 2
  • 5
  • 12
  • you might want to take a look at this: http://stackoverflow.com/questions/3144813/proper-way-to-run-raw-sql-queries-with-sequel – Jeremy C. May 29 '15 at 07:58
  • Or, use a "virtual row" with operators, see http://sequel.jeremyevans.net/rdoc/files/doc/virtual_rows_rdoc.html#label-Operators. – JimmyB May 29 '15 at 07:59

1 Answers1

0

Try either of these

@newnumber = number.find(:all, :conditions => ["id = ?", @dictionary.id], :select => "number * 2 as newnumber")

@newnumber = number.all(:conditions=>"id='#{@dictionary.id}'",:select=>"number * 2 as newnumber")
Matt
  • 14,906
  • 27
  • 99
  • 149