Reputation: 294
Sorry for the nub question. I GTSed this like crazy but came up empty. I'm trying to redirect my page to a draft page but I have no idea what syntax to use. This is where I'm trying to redirect to:
"/stories/:id/draft"
My routes:
# Stories Routes
resources :stories
delete "/stories", to: "stories#destroy"
get "/stories/:id/draft", to: "stories#draft"
This is what I have so far. I don't know how to add the /draft part
redirect_to story_path(story.id)
Thank you!
Upvotes: 1
Views: 27
Reputation: 34318
You can modify your route like this named route:
get "/stories/:id/draft", to: "stories#draft", as: :stories_draft
which will provide you with this:
stories_draft GET /stories/:id/draft(.:format) stories#draft
So, then you can call:
redirect_to stories_draft_path(story)
or,
redirect_to stories_draft_path(story.id)
Upvotes: 1
Reputation: 10111
The way that I like to do this is
match "/stories/:id/draft" => "stories#draft", :as => :stories_draft, via: :all # stories_draft(story.id)
Upvotes: 1