Actions with dashes

2005-10-25
This article is obsolete. You may find it’s replacement at Actions With Dashes – updated

Want to get an action with a dash in it’s name and still do something useful ? Try this:

1 class WelcomeController < ApplicationController
2   define_method("sign-up".to_sym) do
3     if request.post? then
4       # Do something
5     end
6   end
7 end

Of course, if you don’t have anything to do, just name the view file appropriately: app/views/welcome/sign-up.rhtml.