ruby on rails - authlogic current_user tracking -


<'d Html>

I use authlogic for certification and paperclip to the user's profile picture handling attachments.

I use the following method to get the current_use

  defined def current_user_session return @ current_user_session? (@current_user_session) @current_user_session = UserSession.find End Def Current_User return @current_user if defined? (@ Current_user) @current_user = current_user_session & amp; Amp; If the image has changed then the current_user_session.record end  

and the following after_save callback to recreate the profile image.

  after_save do | User | If user.image_changed? Delay :: Job.enqueue ImageJob.new (user.id) and end  

currently used Ughrsasnkfnd call in user mode and see it Ughrseshn docs. Which would update some fields (updated, tokens, etc. but no profile image), resulting in saved user records, which results in a callback firing in my case later. After saving the callback check, to see if there has been a change in the user profile image, which consumes time in idle.

Now it is right that you try to update the user the profile, but when I use current_user hereby

I think it is absolutely authlogic issue , but anyway I did not update you can avoid it, within my app is getting fired many different places, this callback (and an expensive call) that is either user records or In some way What is the profile update and what does this userSession.find login do to differentiate between what happened?

Thanks

Here's the solution that worked on the basis of the suggestions of the BGG.

Phle_swe: Chek_wat_chet

def Chek_vat_cheward if self.changed.sort == [ "last_request_at", "perishable_token"] self.skip_profile_update = true returns true other self .skip_profile_update = false returns End of the true end

Update # 2 I did not take that back to work, but it is not really a problem with this solution, for some reasons, before the attach_save callback paperclip Attempted to save the attachment too. This is a paperclop problem, no idea ..

one before_save In the callback, you can make a difference between an real profile change and authlogic related changes ( last_request_at and updated_at attributes). Objects tracking feature with some of these lines

  attr_accessor: skip_profile_update before_save do | Model | Model.skip_profile_update = (model.changed.sort == ['last_request_at', 'updated_at']) after the end_seave. Model | Until model.skip_profile_update # etc end up  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -