Joel VanderWerf wrote:
I’m pretty sure that’s impossible – there is no #() method, or #()=.
But there is #=, and you can adapt your Proxy approach to use it:
That’s a good suggestion, but unfortunately, it doesn’t fit in my case.
I’m trying to do this stuff in an extension module for a Rails has_many
:through association. It looks roughly like this
class Role < ActiveRecord::Base
validates_presence_of :type # actor, director, …
class Movie < ActiveRecord::Base
has_many :participants, :through => :roles do
self.scoped(…) # joins and conditions omitted
This allows me to write code like
On top of that, I’d like to be able to write
movie.participants.as(‘actor’) = params[:movie][:actors]
and that’s where I’m stuck.