What's New in Edge Rails: Application.rb Duality is no More

Posted by ryan
at 8:36 PM on Tuesday, November 18, 2008

This feature is scheduled for: Rails v2.3/3.0

Ever wonder why your ArticlesController has to live in a file called articles_controller.rb but that special ApplicationController gets to hang out in application.rb? Well no more.. That snooty little controller will now live in application_controller.rb and abide by the same naming restrictions that the rest of us do.

By the time Rails 2.3/3.0 rolls around this rename will happen for you as part of rake rails:update. However, for those of you on Edge Rails, you’ll need to make this change yourself.

tags: ruby, rubyonrails

Comments

Leave a response

  1. MaximNovember 19, 2008 @ 01:09 AM

    While trying edge I stumbled upon another little quirk that should be mentioned. Unit tests must now inherit from ActiveSupport::TestCase as opposed to Test::Unit::TestCase. Otherwise Rails blows up ambiguously saying that the method “use_transactional_fixtures=” in test_helper.rb is undefined.

  2. paulcNovember 19, 2008 @ 02:45 AM

    it would have been better to follow the merb way with controller names being cars.rb instead of cars_controller.rb, simple and to the point

  3. jana4uNovember 19, 2008 @ 05:12 AM

    well, i really hate this behaviour in merb… in rails it could simply be news.rb model and news_controller.rb for controller, but you can’t have news.rb (and News class) for both model and controller.

  4. Antares TraderNovember 19, 2008 @ 01:57 PM

    I agree with jana4u. And would go a step farther to ask why do we have to use specific names for our controller and model class files? Controllers can clearly be identified as anything that inherits from the frameworks controller class. Further, all these classes are defined in files under the $ROOT/app/controller directory. The file naming should be a convention, not a requirement.

  5. paulcNovember 20, 2008 @ 07:00 PM

    yeah, that is even bettter, let people choose.

  6. Matthew HigginsNovember 21, 2008 @ 11:45 AM

    You can choose the name of your controller files, they just won’t autoload.

  7. David ReeseNovember 23, 2008 @ 01:33 PM

    Just a note—

    If you’re on phusion passenger this commit will require you to upgrade to the edge passenger gem. You need to get this commit:

    http://github.com/FooBarWidget/passenger/commit/704489902ea03721b9d5c440ed608d38f3eeddde

    Unfortunately, passenger doesn’t seem to be set up to build github gems—you’ve got to git the source, and per the instructions on the README, compile the gem, and install it. (but don’t run off and do it just yet.)

    I found that I had to install the apache module (“passenger-install-apache2-module”) again, and then update my apache config to use the new passenger version (2.1).

    And then some of my rails apps (both edge and non-edge) stopped starting up and I got 503s with no logs that were helpful in tracking down the problem. ich.

    SO, what I ended up doing was applying the 704489 commit myself—it’s just a few lines of code. On osx I was able to just apply the changes in that commit (above) to this file: /Library/Ruby/Gems/1.8/gems/passenger-2.0.3/lib/passenger/railz/application_spawner.rb

    ...and restart apache. hope somebody else has a better solution?