Please Help!


#1

Ciao PPL!

in our project we use this global method:

application.rb

def set_user_authenticated(user)
self.app_user = user
end

I need to call it from inside a method that belongs to User model…

user.rb

def track_successful_payment(promo, transaction_id)

set_user_authenticated(self)

end

I’ve tried to create a new method:

def track_successful_payment(promo, transaction_id)

self.set_authenticated

end

in user.rb

def set_authenticated
super.set_user_authenticated(self)
end

but I’m not on the right way…

please help this is more than critical right now! :smiley:


#2

You are finding it difficult because it is not a recommended practice
for the model to know anything about the session. The controller that
invokes your model method to track payments should set the
authentication to the user that is involved in the payment if that is
what you want done. Separating these issues of data management and
session management is a key aspect of Rails.

Michael