Rails3RC Notes
1. ruby script/COMMAND....
rails <command >
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"
In addition to those, there are:
application Generate the Rails application code
destroy Undo code generated with "generate"
benchmarker See how fast a piece of code runs
profiler Get profile information from a piece of code
plugin Install a plugin
runner Run a piece of code in the application environment
All commands can be run with -h for more information.
2. it shouldn't autoload #{RAILS_PATH}/lib
in config/application
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths += %W(#{config.root}/lib)
3. error_messages is a plugin...
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`.
4. Validates
class Film < ActiveRecord::Base
validates :title, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
validates :budget, :presence => true, :length => { :within => 1..10000000 }
end
http://thelucid.com/2010/01/08/sexy-validation-in-edge-rails-rails-3/
5. Plugin
Use toplevel init.rb; rails/init.rb is deprecated:
6. Model before_#{create, save, update}
If you want to override the method, you should use self.before_#{create, save, update} instead of before_#{create, save, update}.
7. Validate (DEPRECATION WARNING)
Errors#on have been deprecated, use Errors#[] instead.
8. request#request_uri
DEPRECATION WARNING: Using #request_uri is deprecated. Use fullpath instead.