Forum: Ruby on Rails Please Help!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
359b7a7fc263382baee62d91c1e4c25e?d=identicon&s=25 Emanuele Mek Tozzato (Guest)
on 2007-06-14 22:22
(Received via mailing list)
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! :D
588ab1c0a5610a7e160a3b101abb91e6?d=identicon&s=25 MichaelLatta (Guest)
on 2007-06-14 22:58
(Received via mailing list)
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
This topic is locked and can not be replied to.