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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Sanjiv Jha at Feb 16, 2012 at 10:23 am
    Batch.where(:id => 1).select(:name)
    On Thu, Feb 16, 2012 at 1:09 PM, $wapnil Patil wrote:

    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

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Paul Lopez at Feb 17, 2012 at 9:55 am
    If you are using Rails 3, you can do

    Batch.select(:name).find(1)
    On Thu, Feb 16, 2012 at 6:23 PM, Sanjiv Jha wrote:

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

    On Thu, Feb 16, 2012 at 1:09 PM, $wapnil Patil wrote:

    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

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    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

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Ppizzq at Feb 17, 2012 at 9:54 am
    I guess you are using Raiils 2.*, in rails 2.x, it should be

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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/BtyvBbi1ypAJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 16, '12 at 10:13a
activeFeb 17, '12 at 9:55a
posts4
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase