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

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.
2dddec0f7717cae77ac6bceede6be5bc?d=identicon&s=25 Vinay (Guest)
on 2008-10-11 11: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?
2dddec0f7717cae77ac6bceede6be5bc?d=identicon&s=25 Vinay (Guest)
on 2008-10-13 12: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.