[Rails]
Re: ruby and mysql syntax? tried single quotes, double, none
Stephan Wehner
stephan at buckmaster.ca
Sun Aug 13 17:12:50 GMT 2006
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
--
Posted via http://www.ruby-forum.com/.
More information about the Rails
mailing list