Is this inside a method at all? or just in the class?
I''m not sure about ruby, but in most Oo languages you can only put
declarations in a class. You can''t put in code like that...
you''d put
that in an initialize method or something.
Could you maybe clarify where/how you''re using the code?
Also, why are you using the connection directly? That code looks like
it could be re-written as an active record find statement really
easily:
unless session[:date2use]
session[:date2use] = Prov.find(:all, :order =>
"bill_cycle_date").first.bill_cycle_date.slice(2,10)
end
=> this code might not be error free, i just typed it here...
On Mar 7, 1:47 pm, Jeff Miller
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hello,
> I am just curious as to why I can''t put the following code in the
> application controller:
>
> if session[:date2use]
> else
> @get_latestbill = Prov.connection.select_all("
> SELECT
> prov_bills.bill_cycle_date AS cd
> FROM prov_bills
> ORDER BY bill_cycle_date DESC
> LIMIT 1")
> @latestbill = @get_latestbill.to_s.slice(2,10)
> session[:date2use] = @latestbill
> end
>
> It gives me a "500 Internal Server Error Content-Type: text/html"
error.
> However, when I use it within actions in my other controllers, it works
> perfectly. It would be very helpful in my app if I can use this in my
> Application Controller...
>
> Any ideas?
>
> Thanks,
> - Jeff Miller
> --
> Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---