Sql query into ror query

I want this query into ror form
select name from Batch where id = 1
i want only name
i tried
Batch.find(:all, :conditions => {:id => 1}) it works
but
Batch.find(:name, :conditions => {:id => 1}) not work
please give me suggestion

Batch.where(:id => 1).select(:name)

On Thu, Feb 16, 2012 at 1:09 PM, $wapnil Patil
[email protected]wrote:

You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Josh Software Private Limited http://www.joshsoftware.com

6, Thube Park,
Shivaji Nagar,
Pune - 411005
Office: +91-020-25539995

I guess you are using Raiils 2.*, in rails 2.x, it should be

Batch.find(:all, :conditions => {:id => 1}, :select => “name”)

If you are using Rails 3, you can do

Batch.select(:name).find(1)

On Thu, Feb 16, 2012 at 6:23 PM, Sanjiv J. [email protected]
wrote:

but
http://groups.google.com/group/rubyonrails-talk?hl=en.
Office: +91-020-25539995


You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Either I will find a way or I shall make a way