What Is New in Ruby on Rails 1.2
| Category | Highlights |
|---|---|
| New Features | Page, action, and fragment caching; script/plugin command; ActionMailer multipart support; bulk-operation methods (update_all, delete_all, increment_counter) |
| Improvements | Scaffold controller generator; collection rendering of partials; easier attachment handling in mailers; faster routing lookup |
| Bug Fixes | Fixed memory leak in ActiveRecord associations; corrected MIME type detection for uploads; resolved race condition in session store |
| Breaking Changes | Removed :include option from find; default session store switched to cookie-based; :conditions hash syntax now requires explicit quoting |
| Deprecations | Deprecated script/generate model_controller shortcut; deprecated old style render :text without explicit content_type |
How does Rails 1.2 improve caching for faster page loads?
Rails 1.2 adds built-in page, action, and fragment caching along with sweepers to automatically expire cached fragments.
- Page caching writes a static HTML file that bypasses the Rails stack entirely.
- Action caching runs the controller but stores the full response for identical requests.
- Fragment caching lets you cache reusable view snippets with
cacheblocks.
# config/environments/production.rb
config.action_controller.perform_caching = true
# app/views/articles/show.html.erb
<% cache @article do %>
<%= render @article %>
<% end %>
In practice, teams that enable fragment caching on expensive partials see response times drop by 30-50% without changing business logic.
What new generator and plugin capabilities does Rails 1.2 provide?
Rails 1.2 expands the code-generation toolbox with a dedicated scaffold_controller generator and a first-class plugin installer.
script/generate scaffold_controller MyModelcreates a controller, views, and tests without touching the model.script/plugin install https://example.com/my_plugin.gitfetches and installs a plugin intovendor/pluginsautomatically.- Generators now support
--skip-migrationand--skip-test-unitflags for finer control.
This matters if you want to prototype UI layers quickly while reusing an existing domain model.
How has ActionMailer been enhanced in Rails 1.2?
ActionMailer 1.2 introduces a streamlined mail method, multipart support, and a simple attachments API.
class NotificationMailer < ActionMailer::Base
def welcome(user)
@user = user
mail(
to: @user.email,
subject: "Welcome to MyApp",
body: render_to_string('welcome')
) do |format|
format.html
format.text
attachments['terms.pdf'] = File.read('terms.pdf')
end
end
end
Most teams will replace the older create_email pattern with this single mail call, reducing boilerplate and making multipart emails trivial.
Which ActiveRecord bulk-operation methods were added in Rails 1.2?
Rails 1.2 adds update_all, delete_all, increment_counter, and decrement_counter for efficient mass updates.
Post.update_all("published = 1", ["created_at < ?", 1.week.ago])runs a single SQL UPDATE.Comment.delete_all(:spam => true)issues a single DELETE without loading records.Article.increment_counter(:views, article.id)updates a counter atomically.
These methods matter when processing large data sets; they avoid the N+1 load-save cycle that previously slowed background jobs.
What breaking changes and deprecations should I watch for when upgrading to Rails 1.2?
Upgrading to Rails 1.2 requires attention to three key breaking changes.
- The
:includeoption was removed fromfind; useincludesor explicit joins instead. - Session storage defaults to cookie-based sessions; any code that relied on server-side session files must be migrated.
- Old style
script/generate model_controllershortcuts are deprecated; generate controllers and models separately.
Watch out for failing tests that still reference the removed :include syntax; updating them early saves migration headaches.
Frequently Asked Questions
Can I use the new fragment caching syntax in Rails 1.1 applications?
Fragment caching blocks were introduced in Rails 1.2, so they are not available in 1.1 without back-porting the code.
Do I need to change my database.yml when moving to the cookie-based session store?
No database configuration changes are required; the session data is now stored in the client cookie instead of the server.
How do I generate a controller without a model in Rails 1.2?
Run script/generate scaffold_controller MyController name:string age:integer.
Is the old create_email method still supported in ActionMailer 1.2?
The create_email method is deprecated and will be removed in a future release; use the mail method instead.
What command should I use to install a plugin from a Git repository?
Use script/plugin install https://github.com/example/my_plugin.git.
Will update_all trigger ActiveRecord callbacks?
No, update_all bypasses callbacks and validations, executing a raw SQL UPDATE directly.