Worth noting that error_messages_for is not included, by default, in Rails 3. If you check your console server log you'll see this warning:-
DEPRECATION WARNING: error_messages_for was removed from Rails and is now available as a plugin.
Please install it with `rails plugin install git://github.com/rails/dynamic_form.git`.
After you install the plugin, everything works as expected.
While upgrading one of my Rails 2.3 apps to Rail 3, I came across a few issues when using subdomains with a localhost domain. I have a route like so:-
root :to => 'controller#page', :constraints => {:subdomain => "subdomain1"}
I had a test subdomain set-up in my /etc/hosts file as usual. For instance, here is the first line in my /etc/hosts file:-
127.0.0.1 subdomain1.localhost
So, if I request the url http://subdomain1.localhost:3000, Rails 3 treats "subdomain1.localhost" as the domain. In other words, it is treating "localhost" as the TLD.
To fix this I changed my test subdomain, in the /etc/hosts file, to have a TLD, like so:-
127.0.0.1 subdomain1.localhost.local
And hey presto, as if by magic, it now works.
UPDATE: Changed TLD to .local (makes more sense)
I've been having a great time using Compass when working on meetee recently. In particular, I've been making use of the CSS3 mixins.
The mixins for Text Shadow, Box Shadow and Gradient have been really useful. No need to worry about any cross-browser compatibility issues - compass takes care of this for you. Plus you're left with more concise code.
The new documentation is looking really nice as well! Highly recommended.
I was just looking into including some Rack middleware in my Rails 3 app. One thing confused me slightly. There seems to be two ways that you can include middleware in you app:-
Note: I'm using the codehighlighter rack middleware for this example.
I'm not sure what is the recommended way, however, I think it seems best placed in the config.ru file (since this file is directly related to Rack). In the Rails edge documentation it says that you should use the config.middleware method in the "environment.rb" file... surely this couldn't be right?
Came up against this recently when trying to upgrade a Rails app which was using MongoDB. Obviously I didn't want to use ActiveRecord, so I set about removing it.
The old way of removing ActiveRecord was to place this line in the environment.rb file, "config.frameworks -= [ :active_record ]". However, in Rails 3 you can simply pass the "-O" switch to the rails command, like so:-
rails yourapp -O
But what if you've already created your app? If you look in your config/application.rb file, you'll see this line at the top:-
require 'rails/all'
This does what it says on the tin; includes all rails modules. If you want to exclude ActiveRecord, remove the above line and replace it with:-
# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
This is the beauty of Rails 3, pick and choose what suits you.