Kishoj B. wrote in post #966523:> I use the SQL code in the controller as follow:
>
> sql = ActiveRecord::Base.connection();
> @countlikes = sql.execute("SELECT COUNT(rateint) as result FROM
> rates");
>
> But it returns the resuls as #<PGresult:0xb6ea00e0> in the view i.e.
> @countlikes = #<PGresult:0xb6ea00e0>
>
> I wanted the integer value. I am wondering how to use sql codes in the
> controller
You don''t need to. Look up the docs for ActiveRecord::Calculations.
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
Sent from my iPhone
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
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.