Hi Colin

first of all, thank you very much for your help!! You found the root cause 
of my problem.

After user session expired, the code:

ActiveRecord::Base.establish_connection({:adapter => "mysql", :database => 
"#{current_user.dbname}", :username => "x", :password => "x", :host => "x", 
:encoding => "utf8"})

didn't work, but also didn't throw any exception. So the requested view got 
the last opened database connection to retrieve the records. Of course, the 
records retrieved was from another user (the last 
successful establish_connection attempt).

Thank you all for the support!!

Best regards



Em quarta-feira, 20 de novembro de 2013 15h09min18s UTC-2, Paulo Henrique 
Leite de Castro escreveu:
>
> Hi Colin,
>
> I wasn't able to find any exception referring to this specific line code.
> But, in case of an exception, Rails would return a 500 error page and not 
> the correct page with someone else records. Am I right?
>
> Best regards
>
> Em quarta-feira, 20 de novembro de 2013 14h58min40s UTC-2, Colin Law 
> escreveu:
>>
>> On 20 November 2013 16:52, Paulo Henrique Leite de Castro 
>> <[email protected]> wrote: 
>> > Hi Fred, thanks for your reply! 
>> > 
>> > I'm using authlogic gem to authenticate my users. 
>> > 
>> > Inside my Application Controller I created the following code: 
>> > 
>> > prepend_before_filter :database_connection 
>> > 
>> > and this method has the following code: 
>> > 
>> > ActiveRecord::Base.establish_connection({:adapter => "mysql", :database 
>> => 
>> > "#{current_user.dbname}", :username => "x", :password => "x", :host => 
>> "x", 
>> > :encoding => "utf8"}) 
>>
>> Are you checking for an error return here in case it fails for some 
>> reason, leaving the connection as it was for the last request?  Also I 
>> presume you are not silently absorbing any exception raised there. 
>>
>> Colin 
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/edbf9d9d-543d-430d-9536-b6ded6ea58d9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to