small medium large xlarge

Ruby_pragsmall
23 Nov 2008, 19:02
Alfredo Rico Moros (2 posts)

Hi to everyboy.. I need your help in order to know if I get wrong..

I’m using rails 2.2.2 with MySQL 5.0

I have this migration file:

class CreateSpecifications < ActiveRecord::Migration def self.up create_table :specifications do |t| t.string :tolerancia t.integer :umbral

  t.timestamps
end   end

def self.down drop_table :specifications end end

I put some data by mean of script/console Specification.create(:umbral => 33, :tolerancia => ‘alta’) Specification.create(:umbral => 23, :tolerancia => ‘alta’) Specification.create(:umbral => 12, :tolerancia => ‘baja’) Specification.create(:umbral => 33, :tolerancia => ‘baja’)

Then when I run the following statement Specification.find(:all, :select => ‘tolerancia, sum(umbral) as total’, :group => ‘tolerancia’)

I get the following: [#<Specification tolerancia: “alta”>, #<Specification tolerancia: “baja”>]

Where is my total field??? How could I get it???

Besides, whit the following statement: » Specification.find(:first, :select => ‘now() as ahora’) => #

Where is my field ‘ahora’?

I have ran this situation on Heroku.com with the same sadly results..

Thanks in advanced by your help…

Ruby_pragsmall
23 Nov 2008, 19:06
Alfredo Rico Moros (2 posts)

Apologize, a mistake of copy and paste..

This is the output..

Specification.find(:all, :select => ‘tolerancia, sum(umbral) as total’, :group => ‘tolerancia’) => [#<Specification tolerancia: “alta”>, #<Specification tolerancia: “baja”>]

Where is my total field??

You must be logged in to comment