Hello All

This is my first time on ruby-forum so pardon if this is not posted
correctly.

I am having a very similar issue regarding has_many through has_many.  A
logged user can create a work order and associated fields in models name
alias and sub_tasks.  I am using active_admin and an admin user can view
and edit the above mentioned models, but when admin tries to create a
sub_task I can get the following error:

Cannot modify association 'WorkOrder#sub_tasks' because the source
reflection class 'SubTask' is associated to 'NameAlias' via :has_many.

the models:

 class work_order < ActiveRecord::Base
  has_many :name_aliases
  has_many :sub_tasks, :through => :name_aliases
end

class NameAlias < ActiveRecord::Base
  belongs_to :work_order
  has_many :sub_tasks
end

class SubTask < ActiveRecord::Base
  belongs_to :name_alias
  belongs_to :work_order
end

A pervious post mentioned a solution using an after_save method  before
declaring the association... but I didn't see sample code? since i am
new to rails it would be helpful to see or example how this can be
resolved.  Thanks for your help!

Best,
Fritz

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to