Reputation: 34523
Let's say we want to create an unsubscribe page in Rails.
Is it possible to create a single www.website.com/unsubscribe URL that renders the unsubscribe form on a GET request, but directs to a different controller method upon a form request?
In other words, we want to mimic the default resources functionality but not for something that maps to an ActiveRecord.
We're on Rails 3.2.12.
Upvotes: 0
Views: 78
Reputation: 2868
Yes, it is possible.
get 'subscribe', to: 'controller#unsubscribe_form'
post 'subscribe', to: 'controller#unsubscribe'
Upvotes: 1