Forum: Ruby on Rails Virtual attribute setter method in model, how to write a scoped query?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Vinay (Guest)
on 2008-10-11 13:16
(Received via mailing list)
I have a form that has a virtual attribute 'contact_name'. In the
setter method for this, I need to scope the query through
current_user.contacts.find (etc). But current_user is a helper method
(RESTful authentication) and it is apparently not available in the
model (where the setter method is located). I tried..
[code=]@current_user = User.find(params[:user_id])
@contact = @current_user.contacts.find (etc)[/code]
.. but the params hash too is not available. How can I scope the query
through the current_user in the model file?
Vinay (Guest)
on 2008-10-13 14:58
(Received via mailing list)
anyone got any ideas? i really need a solution for this to get a
feature working.
This topic is locked and can not be replied to.