hyper-mesh
hyper-mesh copied to clipboard
support association proxy actions like create
Consider Todo
belongs_to :user
:
Todo.create user_id: some_user.id, ...
works, but
some_user.todos.create ...
results in RuntimeError: Clock._create_synchromesh_scope_description_() (called class method missing)
a has_many relationship (like todos
) is represented on the client by an object of class ReactiveRecord::Collection.
I think all that has to be done, is add the create
method to Collection
approx like this:
def create(attrs = {}, &block)
new_record = @target_klass.new(attrs)
self << new_record
new_record.save(&block)
end
@catmando From the first look at it, I don't think this will suffice, unless <<
sets the reference attr which I doubt.
@costa yes << does work. I'll add this into the next update