On 14 January 2012 04:12, Fritz Rodriguez <li...@ruby-forum.com> wrote:
> 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

This should be belongs_to :through name_alias.  It must mirror the
has_many sub_tasks :through in work_order

You should really have started a new thread for this as it is nothing
to do with the original post.

Colin

-- 
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to