Monday, June 30, 2008

Note to self: Don't create an ActiveRecord model named Action

Finally getting around to noting something I ran across several days ago.  While debugging a Ruby on Rails hobby app of mine I had a head-slapping moment when I realized the source of my pain was from blithely naming an ActiveRecord Model Action.

What's the big deal?

ActionPack already expects there to be a params[:action] completely unrelated to a Model named Action (which gets translated to params[:action] when submitting a form for @action).  I subsequently read Josh Susser's post on using Reference as a Model name where it conflicted with a reserved word in MySQL.  This got me to thinking that it would sure be nice if the rails generators might spit out a friendly "hey dork, that's probably not a good idea to use that name..." kind of message.  Perhaps I'll take a crack at that eventually.

0 comments: