current_user is only available in your controllers/views. If it was available in models, that would break the model/view paradigm.

There are two places where the user is available in models in Hobo:

- permissions
- lifecycles
- creator attributes (http://cookbook.hobocentral.net/manual/model#creator)

In both of those cases, the user is either a parameter or a "pseudo-parameter" so that the model/view paradigm is not broken. That explains why "acting_user" is only available from within permission functions, and not for all methods in your model. It's also why you have to use `record.creatable_by?(user)` and friends when using permission functions directly.

That means you have three options:

1) Pass the current_user to your model in a controller action
2) use the creator attribute
3) use lifecycles

It sounds like #2 won't work for you.

#1 is as simple as:

def update
  self.this = find_instance
  self.this.some_function(current_user)
  hobo_update
end

or:

def update
  hobo_update
  self.this.some_other_function(current_user)
end

I'd look seriously into #3 as well -- non-standard controller actions are often a sign that you need a lifecycle.

Bryan

Tom wrote:
I need to get in one model's setter of a field the info about current
user (exactly who made that operation). How can I do that? I need
user's login to find his signature and add it to the field of another
model. User model and this other model are not associated.


--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to