I have a model Post
:
class Post < ActiveRecord::Base
has_one :draft, class_name: Post, foreign_key: draft_id
end
In routes.rb
I have the following:
namespace :admin do
resources :posts do
resource :draft
end
end
What I want to achieve is to enable drafts when using form_for
, i.e.:
= form_for [:admin, @post, @draft] do |form|
...where @post
and @draft
are different instances of the same model.
Right now if I do that, I get an error:
NoMethodError: undefined method `admin_tour_tour_url'
Question: So how do I make the form generate admin_tour_draft_url
+ with a needed modifiers like edit_
and new_
?
P.S. am I going the wrong path here?