このRESTfulを維持しながら、関連付け自体を破棄し、関連付けられているオブジェクトをそのままにしておくにはどうすればよいですか?
具体的には、次のモデルがあります。
class Event < ActiveRecord::Base
has_many :model_surveys, :as => :surveyable, :dependent => :destroy, :include => :survey
has_many :surveys, :through => :model_surveys
end
class ModelSurvey < ActiveRecord::Base
belongs_to :survey
belongs_to :surveyable, :polymorphic => true
end
class Survey < ActiveRecord::Base
has_many :model_surveys
end
つまり、イベントは:surveyable
(ModelSurvey belongs_to Event
)です。私の質問は、を作成する必要なしに、をそのままにして、どうModelSurveysController
すれば破壊することができるかということです。ModelSurvey
Event
Survey
何か map.resources :events, :has_many => :model_surveys
?この状況で何をすべきかよくわかりません。ルートで何が起こる必要があり、コントローラーで何が起こる必要がありますか?URLが次のようになることを願っています:
/events/:title/model_surveys/:id
助けてくれてありがとう、ランス