Ruby and mysql syntax? tried single quotes, double, none,

Hi, how do i use passed in arguments and convert those to something sql
can understand? do the aliases have to be double qouted? single qouted?
i think i tried all but no avail…thanks!

def get_count(doctype, towne)

@profiles = Profile.count_by_sql(“SELECT COUNT(*) from Profiles where
Profiles.doctype_id = 1 and town_id = towne”)

end

koloa wrote:

Hi, how do i use passed in arguments and convert those to something sql
can understand? do the aliases have to be double qouted? single qouted?
i think i tried all but no avail…thanks!

def get_count(doctype, towne)

@profiles = Profile.count_by_sql(“SELECT COUNT(*) from Profiles where
Profiles.doctype_id = 1 and town_id = towne”)

end

Try

Profile.count_by_sql([“SELECT COUNT(*) from Profiles where
Profiles.doctype_id = ? and town_id = ?”, doctype, towne])

or look for examples at

http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000870

Stephan

Hello Stephan, Thanks!

or look for examples at

http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000870

Stephan

Hi Stephan,
i have the same issue as discuss here. i try above given link but
it is not working. could you give me the other link or some direction to
avoid the Double Quotes problem.

Thanks
Salil

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs