Sijo Kg wrote: > Hi > I have the model SDTicket and SDCi > SDTicket > has_many :service_desk_cis > > SDCi > after_save :update_sd_ticket > belongs_to :sd_ticket > def update_sd_ticket > self.sd_ticket.update_attribute("modified_by_id",#here I need value > from session) > end > > I have a user controller in that session[:id] = current_user_id #here I > am setting current user id to session[:id] > > Could you please tell me how I can access this value from SDCi > class above in the call back after_save > I can't (personally). I would probably create an instance method in the model inside which I would save the model (self.save) and do other things like update the related model. If you do it this way you could also wrap it in a transaction block to make the whole thing atomic - at least you have that option anyway.
You'd pass the session value in as an argument to this method from the controller; your model shouldn't need to know about where the current_user_id came from (ie someone's http session). This makes things more testable / less coupled. That's just my thoughts. -- Daniel Bush -- Posted via http://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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---