An alternative would be to create two “register” routes. One that accepts only GET requests (and jumps to: the new action), and another that accepts only POST requests (and jumps to the create action, but displays the same template as the new one).
It might look like this:
map.get_register 'register', :controller => :registrations,
:action => :new, :conditions => { :method => :get }
map.post_register 'register', :controller => :registrations,
:action => :create, :conditions => { :method => :post }
:
def new
@registration = Registration.new
end
def create
@registration = Registration.new(params[:registration])
return render(:action => :new) unless @registration.save
end
, :