Rails 3, Webrick, Mac OS X, Error: missing :action (ArgumentError)

I was making some changes in a routes.rb file and fat fingered the wrong line:

match '/public_html', "domains#public_html", :as => 'public'

Ran rails server, hit localhost:3000 and quickly saw a huge stack trace with this little gem of an error at the top:

/Users/miker/projects/projects/logthingy/vendor/bundle/ruby/1.8/gems/actionpack-3.0.7/lib/action_dispatch/routing/mapper.rb:171:in `default_controller_and_action': missing :action (ArgumentError)

To me, that error message is not the most helpful. Because the only change I had made was in routes.rb I knew the issue was there. By the way, this is where I feel a little bit sorry for newcomers to Ruby and Rails… The error messages are not always entirely clear. For those of us who have been in Ruby long enough to know the “breadcrumb logic” we can get by, but for those who don’t it can be a nightmare.

The fix was simple and subtle… was missing some punctuation:

match '/public_html' => "domains#public_html", :as => 'public'


Leave a Reply

Your email address will not be published. Required fields are marked *