Rails 2.0: It's done!
Posted by David December 07, 2007 @ 03:03 PM
Rails 2.0 is finally finished after about a year in the making. This is a fantastic release that’s absolutely stuffed with great new features, loads of fixes, and an incredible amount of polish. We’ve even taken a fair bit of cruft out to make the whole package more coherent and lean.
What a milestone for Ruby on Rails as well. I’ve personally been working on this framework for about four and a half years and we have contributors who’ve been around for almost as long as well. It’s really satisfying to see how far we’ve come in that period of time. That we’ve proven the initial hype worthy, that we’ve been able to stick with it and continue to push the envelope.
Before jumping into the breakdown of features, I’d just like to extend my deep gratitude towards everyone who helped make this release possible. From the stable of merry men in the Rails core to the hundreds of contributors who got a patch applied to everyone who participated in the community over the year. This release is a triumph for large-scale open source development and you can all be mighty proud of the role you played. Cheers!
With the touchy-feely stuff out of the way, let’s dig into the feast and look at just a sliver of what’s new:
Action Pack: Resources
This is where the bulk of the action for 2.0 has gone. We’ve got a slew of improvements to the RESTful lifestyle. First, we’ve dropped the semicolon for custom methods instead of the regular slash. So /people/1;edit is now /people/1/edit. We’ve also added the namespace feature to routing resources that makes it really easy to confine things like admin interfaces:
map.namespace(:admin) do |admin|
admin.resources :products,
:collection => { :inventory => :get },
:member => { :duplicate => :post },
:has_many => [ :tags, :images, :variants ]
end
Which will give you named routes like inventory_admin_products_url and admin_product_tags_url. To keep track of this named routes proliferation, we’ve added the “rake routes” task, which will list all the named routes created by routes.rb.
We’ve also instigated a new convention that all resource-based controllers will be plural by default. This allows a single resource to be mapped in multiple contexts and still refer to the same controller. Example:
# /avatars/45 => AvatarsController#show
map.resources :avatars
# /people/5/avatar => AvatarsController#show
map.resources :people, :has_one => :avatar
Action Pack: Multiview
Alongside the improvements for resources come improvements for multiview. We already have #respond_to, but we’ve taken it a step further and made it dig into the templates. We’ve separated the format of the template from its rendering engine. So show.rhtml now becomes show.html.erb, which is the template that’ll be rendered by default for a show action that has declared format.html in its respond_to. And you can now have something like show.csv.erb, which targets text/csv, but also uses the default ERB renderer.
So the new format for templates is action.format.renderer. A few examples:
- show.erb: same show template for all formats
- index.atom.builder: uses the Builder format, previously known as rxml, to render an index action for the application/atom+xml mime type
- edit.iphone.haml: uses the custom HAML template engine (not included by default) to render an edit action for the custom Mime::IPHONE format
Speaking of the iPhone, we’ve made it easier to declare “fake” types that are only used for internal routing. Like when you want a special HTML interface just for an iPhone. All it takes is something like this:
# should go in config/initializers/mime_types.rb
Mime.register_alias "text/html", :iphone
class ApplicationController < ActionController::Base
before_filter :adjust_format_for_iphone
private
def adjust_format_for_iphone
if request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPod)/]
request.format = :iphone
end
end
end
class PostsController < ApplicationController
def index
respond_to do |format|
format.html # renders index.html.erb
format.iphone # renders index.iphone.erb
end
end
end
You’re encouraged to declare your own mime-type aliases in the config/initializers/mime_types.rb file. This file is included by default in all new applications.
Action Pack: Record identification
Piggy-backing off the new drive for resources are a number of simplifications for controller and view methods that deal with URLs. We’ve added a number of conventions for turning model classes into resource routes on the fly. Examples:
# person is a Person object, which by convention will
# be mapped to person_url for lookup
redirect_to(person)
link_to(person.name, person)
form_for(person)
Action Pack: HTTP Loving
As you might have gathered, Action Pack in Rails 2.0 is all about getting closer with HTTP and all its glory. Resources, multiple representations, but there’s more. We’ve added a new module to work with HTTP Basic Authentication, which turns out to be a great way to do API authentication over SSL. It’s terribly simple to use. Here’s an example (there are more in ActionController::HttpAuthentication):
class PostsController < ApplicationController
USER_NAME, PASSWORD = "dhh", "secret"
before_filter :authenticate, :except => [ :index ]
def index
render :text => "Everyone can see me!"
end
def edit
render :text => "I'm only accessible if you know the password"
end
private
def authenticate
authenticate_or_request_with_http_basic do |user_name, password|
user_name == USER_NAME && password == PASSWORD
end
end
end
We’ve also made it much easier to structure your JavaScript and stylesheet files in logical units without getting clobbered by the HTTP overhead of requesting a bazillion files. Using javascript_include_tag(:all, :cache => true) will turn public/javascripts/.js into a single public/javascripts/all.js file in production, while still keeping the files separate in development, so you can work iteratively without clearing the cache.
Along the same lines, we’ve added the option to cheat browsers who don’t feel like pipelining requests on their own. If you set ActionController::Base.asset_host = “assets%d.example.com”, we’ll automatically distribute your asset calls (like image_tag) to asset1 through asset4. That allows the browser to open many more connections at a time and increases the perceived speed of your application.
Action Pack: Security
Making it even easier to create secure applications out of the box is always a pleasure and with Rails 2.0 we’re doing it from a number of fronts. Most importantly, we now ship we a built-in mechanism for dealing with CRSF attacks. By including a special token in all forms and Ajax requests, you can guard from having requests made from outside of your application. All this is turned on by default in new Rails 2.0 applications and you can very easily turn it on in your existing applications using ActionController::Base.protect_from_forgery (see ActionController::RequestForgeryProtection for more).
We’ve also made it easier to deal with XSS attacks while still allowing users to embed HTML in your pages. The old TextHelper#sanitize method has gone from a black list (very hard to keep secure) approach to a white list approach. If you’re already using sanitize, you’ll automatically be granted better protection. You can tweak the tags that are allowed by default with sanitize as well. See TextHelper#sanitize for details.
Finally, we’ve added support for HTTP only cookies. They are not yet supported by all browsers, but you can use them where they are.
Action Pack: Exception handling
Lots of common exceptions would do better to be rescued at a shared level rather than per action. This has always been possible by overwriting rescue_action_in_public, but then you had to roll out your own case statement and call super. Bah. So now we have a class level macro called rescue_from, which you can use to declaratively point certain exceptions to a given action. Example:
class PostsController < ApplicationController
rescue_from User::NotAuthorized, :with => :deny_access
protected
def deny_access
...
end
end
Action Pack: Cookie store sessions
The default session store in Rails 2.0 is now a cookie-based one. That means sessions are no longer stored on the file system or in the database, but kept by the client in a hashed form that can’t be forged. This makes it not only a lot faster than traditional session stores, but also makes it zero maintenance. There’s no cron job needed to clear out the sessions and your server won’t crash because you forgot and suddenly had 500K files in tmp/session.
This setup works great if you follow best practices and keep session usage to a minimum, such as the common case of just storing a user_id and a the flash. If, however, you are planning on storing the nuclear launch codes in the session, the default cookie store is a bad deal. While they can’t be forged (so is_admin = true is fine), their content can be seen. If that’s a problem for your application, you can always just switch back to one of the traditional session stores (but first investigate that requirement as a code smell).
Action Pack: New request profiler
Figuring out where your bottlenecks are with real usage can be tough, but we just made it a whole lot easier with the new request profiler that can follow an entire usage script and report on the aggregate findings. You use it like this:
$ cat login_session.rb
get_with_redirect '/'
say "GET / => #{path}"
post_with_redirect '/sessions', :username => 'john', :password => 'doe'
say "POST /sessions => #{path}"
$ ./script/performance/request -n 10 login_session.rb
And you get a thorough breakdown in HTML and text on where time was spent and you’ll have a good idea on where to look for speeding up the application.
Action Pack: Miscellaneous
Also of note is AtomFeedHelper, which makes it even simpler to create Atom feeds using an enhanced Builder syntax. Simple example:
# index.atom.builder:
atom_feed do |feed|
feed.title("My great blog!")
feed.updated((@posts.first.created_at))
for post in @posts
feed.entry(post) do |entry|
entry.title(post.title)
entry.content(post.body, :type => 'html')
entry.author do |author|
author.name("DHH")
end
end
end
end
We’ve made a number of performance improvements, so asset tag calls are now much cheaper and we’re caching simple named routes, making them much faster too.
Finally, we’ve kicked out in_place_editor and autocomplete_for into plugins that live on the official Rails SVN.
Active Record: Performance
Active Record has seen a gazillion fixes and small tweaks, but it’s somewhat light on big new features. Something new that we have added, though, is a very simple Query Cache, which will recognize similar SQL calls from within the same request and return the cached result. This is especially nice for N+1 situations that might be hard to handle with :include or other mechanisms. We’ve also drastically improved the performance of fixtures, which makes most test suites based on normal fixture use be 50-100% faster.
Active Record: Sexy migrations
There’s a new alternative format for declaring migrations in a slightly more efficient format. Before you’d write:
create_table :people do |t|
t.column, "account_id", :integer
t.column, "first_name", :string, :null => false
t.column, "last_name", :string, :null => false
t.column, "description", :text
t.column, "created_at", :datetime
t.column, "updated_at", :datetime
end
Now you can write:
create_table :people do |t|
t.integer :account_id
t.string :first_name, :last_name, :null => false
t.text :description
t.timestamps
end
Active Record: Foxy fixtures
The fixtures in Active Record has taken a fair amount of flak lately. One of the key points in that criticism has been the work with declaring dependencies between fixtures. Having to relate fixtures through the ids of their primary keys is no fun. That’s been addressed now and you can write fixtures like this:
# sellers.yml
shopify:
name: Shopify
# products.yml
pimp_cup:
seller: shopify
name: Pimp cup
As you can see, it’s no longer necessary to declare the ids of the fixtures and instead of using seller_id to refer to the relationship, you just use seller and the name of the fixture.
Active Record: XML in, JSON out
Active Record has supported serialization to XML for a while. In 2.0 we’ve added deserialization too, so you can say Person.new.from_xml(“
Active Record: Shedding some weight
To make Active Record a little leaner and meaner, we’ve removed the acts_as_XYZ features and put them into individual plugins on the Rails SVN repository. So say you’re using acts_as_list, you just need to do ./script/plugin install acts_as_list and everything will move along like nothing ever happened.
A little more drastic, we’ve also pushed all the commercial database adapters into their own gems. So Rails now only ships with adapters for MySQL, SQLite, and PostgreSQL. These are the databases that we have easy and willing access to test on. But that doesn’t mean the commercial databases are left out in the cold. Rather, they’ve now been set free to have an independent release schedule from the main Rails distribution. And that’s probably a good thing as the commercial databases tend to require a lot more exceptions and hoop jumping on a regular basis to work well.
The commercial database adapters now live in gems that all follow the same naming convention: activerecord-XYZ-adapter. So if you gem install activerecord-oracle-adapter, you’ll instantly have Oracle available as an adapter choice in all the Rails applications on that machine. You won’t have to change a single line in your applications to take use of it.
That also means it’ll be easier for new database adapters to gain traction in the Rails world. As long as you package your adapter according to the published conventions, users just have to install the gem and they’re ready to roll.
Active Record: with_scope with a dash of syntactic vinegar
ActiveRecord::Base.with_scope has gone protected to discourage people from misusing it in controllers (especially in filters). Instead, it’s now encouraged that you only use it within the model itself. That’s what it was designed for and where it logically remains a good fit. But of course, this is all about encouraging and discouraging. If you’ve weighed the pros and the cons and still want to use with_scope outside of the model, you can always call it through .send(:with_scope).
ActionWebService out, ActiveResource in
It’ll probably come as no surprise that Rails has picked a side in the SOAP vs REST debate. Unless you absolutely have to use SOAP for integration purposes, we strongly discourage you from doing so. As a naturally extension of that, we’ve pulled ActionWebService from the default bundle. It’s only a gem install actionwebservice away, but it sends an important message none the less.
At the same time, we’ve pulled the new ActiveResource framework out of beta and into the default bundle. ActiveResource is like ActiveRecord, but for resources. It follows a similar API and is configured to Just Work with Rails applications using the resource-driven approach. For example, a vanilla scaffold will be accessible by ActiveResource.
ActiveSupport
There’s not all that much new in ActiveSupport. We’ve a host of new methods like Array#rand for getting a random element from an array, Hash#except to filter down a hash from undesired keys and lots of extensions for Date. We also made testing a little nicer with assert_difference. Short of that, it’s pretty much just fixes and tweaks.
Action Mailer
This is a very modest update for Action Mailer. Besides a handful of bug fixes, we’ve added the option to register alternative template engines and assert_emails to the testing suite, which works like this:
- Assert number of emails delivered within a block: assert_emails 1 do post :signup, :name => ‘Jonathan’ end
Rails: The debugger is back
To tie it all together, we have a stream of improvements for Rails in general. My favorite amongst these is the return of the breakpoint in form of the debugger. It’s a real debugger too, not just an IRB dump. You can step back and forth, list your current position, and much more. It’s all coming from the gracious note of the ruby-debug gem. So you’ll have to install that for the new debugger to work.
To use the debugger, you just install the gem, put “debugger” somewhere in your application, and then start the server with—debugger or -u. When the code executes the debugger command, you’ll have it available straight in the terminal running the server. No need for script/breakpointer or anything else. You can use the debugger in your tests too.
Rails: Clean up your environment
Before Rails 2.0, config/environment.rb files every where would be clogged with all sorts of one-off configuration details. Now you can gather those elements in self-contained files and put them under config/initializers and they’ll automatically be loaded. New Rails 2.0 applications ship with two examples in form of inflections.rb (for your own pluralization rules) and mime_types.rb (for your own mime types). This should ensure that you need to keep nothing but the default in config/environment.rb.
Rails: Easier plugin order
Now that we’ve yanked out a fair amount of stuff from Rails and into plugins, you might well have other plugins that depend on this functionality. This can require that you load, say, acts_as_list before your own acts_as_extra_cool_list plugin in order for the latter to extend the former.
Before, this required that you named all your plugins in config.plugins. Major hassle when all you wanted to say was “I only care about acts_as_list being loaded before everything else”. Now you can do exactly that with config.plugins = [ :acts_as_list, :all ].
And hundreds upon hundreds of other improvements
What I’ve talked about above is but a tiny sliver of the full 2.0 package. We’ve got literally hundreds of bug fixes, tweaks, and feature enhancements crammed into Rails 2.0. All this coming off the work of tons of eager contributors working tirelessly to improve the framework in small, but important ways.
I encourage you to scourger the CHANGELOGs and learn more about all that changed.
So how do I upgrade?
If you want to move your application to Rails 2.0, you should first move it to Rails 1.2.6. That’ll include deprecation warnings for most everything we yanked out in 2.0. So if your application runs fine on 1.2.6 with no deprecation warnings, there’s a good chance that it’ll run straight up on 2.0. Of course, if you’re using, say, pagination, you’ll need to install the classic_pagination plugin. If you’re using Oracle, you’ll need to install the activerecord-oracle-adapter gem. And so on and so forth for all the extractions.
So how do I install?
To install through gems, do:
gem install rails -y
...if you’re having trouble with that (gem not found), just grab gems from our own repository in the meanwhile:
gem install rails -y --source http://gems.rubyonrails.org
To try it from an SVN tag, use (you may need to run this command twice depending on your current Rails version):
rake rails:freeze:edge TAG=rel_2-0-1
Note: It’s 2.0.1 because we found a small issue just after we pushed 2.0.0.

You might want to consider moving the note to the top of this blog entry.
Congrats !!
(you don’t need the -y option with RubyGems 0.9.5)
Is the activeresource-2.0.1 gem published yet ? I can’t install it.
Thanks
It is, just haven’t propagated yet. Just use the http://gems.rubyonrails.org server to get it.
Congratulations David. When I announced it in my blog, most people didn’t believe it. An awesome early Christmas present this year. :)
ok, i can see now activeresource-2.0.1 gem in http://rubyforge.org/frs/?group_id=3507. Thanks !
Congratulations! Thanks to all the rails hackers who worked on this. You all rock.
Congratulations David, I waited for long and finally it’s out!!
Grats. I love you all.
Excellent!
Due to circumstances beyond my control I’ve been away from Rails for a while, but today I decided to come back. I checked for updates and it just so happens to be 2.0 release day.
Keep up the good work.
Thanks guys. Just to pre-empt any bug reports in the comments, please do post those straight to dev.rubyonrails.org. Thanks and enjoy.
Hooray! Thanks, guys! You rock!
Congratulations!
Great
Excellent job guys. Thanks a bunch for all your hard work.
Awesome! I just started porting my site to RC2 a few days ago, and I’m just finishing things up… Excellent timing :)
Nice work! I love the fact that so much effort has been placed on cleaning up and already nicely organized dev platform.
Congrats and thanks!
More about sexy migrations:
Before you’d write:
create_table :people do |t| t.column, “account_id”, :integer t.column, “first_name”, :string, :null => false t.column, “last_name”, :string, :null => false t.column, “description”, :text t.column, “created_at”, :datetime t.column, “updated_at”, :datetime end
Now you can write:
create_table :people do |t| t.references :account t.string :first_name, :last_name, :null => false t.text :description t.timestamps end
Or:
create_table :people do |t| t.belongs_to :account t.string :first_name, :last_name, :null => false t.text :description t.timestamps end
Notice we no longer needs to do t.integer foobar_id . :)
Awesome work. What’s the current best guess for what it will take to run it on Ruby 1.9?
“Does it scale?” ;)
Thanks for the big work to all the team.
Congratulations to the Rails team! I’m interested to see what effect the changes as a whole are going to have on my code practices and architecture. Only one way to find out!
Grats everyone! Good times.
Congrats on the solid release! I’m already rubbing my hand in anticipation of running Rails 2.0+ on Ruby 1.9. Let’s get to Ruby 1.9 compatibility next! :)
Oh that reminds me, what would the next milestones be? I’m under the impression that rendering will be looked into, and I’m expecting that Ruby 1.9 compat will be one of the few things that the core team is planning on patching as well, right?
RE: comment 22.
Yikes, that would be “rubbing my hands tegother”.
Congrats David.. a very good christmas gift!!!
@Chu Yeow
A lot of exploratory work and updates have already been made for 1.9 compatibility, mostly by Jeremy Kemper. So Rails 2.0 isn’t that far off from being 1.9 ready.
Ouch! Ugly rendering for code in comments. I’ll try a new one..
Before you’d write:
create_table :taggings do |t|
t.integer :tag_id, :tagger_id, :taggable_id
t.string :tagger_type
t.string :taggable_type, :default => ‘Photo’
end
Now you can write:
create_table :taggings do |t|
t.references :tag
t.references :tagger, :polymorphic => true
t.references :taggable, :polymorphic => { :default => ‘Photo’ }
end
And t.belongs_to is an alias for t.references
More about that in: http://dev.rubyonrails.org/changeset/7973
Thanks once again for your excellent work!
Session on the user-side ? WTF ?! It’s the worse idea I have ever heard.
Session on the user-side ? WTF ?! It’s the worse idea I have ever heard.
bloated => bad RESTful => bad Rails 1.0 > Rails 2.0
for me Rails isn’t the best Framework anymore… That’s a pity
Awesome!!! Making me more in love with Rails! _
I am sooo happy with rails 2.0.1! I am also waiting to buy the pragmatic guide!!
Best regards to you all!!!
Good
Party!!! Thank you Rails Team.
congrats, wonderful release =)
woot
well done guys, lots of hard work went into this, so glad it’s out!
Excellent!
Great work, thank you guys!
Gratulations. I think with 2.0 it’s time to create an update of the famous whoops.mov ;)
Congrats!! And good job to everyone who made it happen!
Awesome! Im looking forward to this very much so. Great Job guys.
Hi,
Im using locomotive and when I updated to rails 2.0.1 not much happend. IT installed with no errors, but weheever I try to view my app it still uses version 1.2.6….. Whats wrong?
YAY! Great effort guys. Much appreciated.
Congratulations guys! I’m preparing a review for this release in Portuguese – it sounds awesome.
Just shy of a week under 2 years since 1.0 was officially out (2005/12/13). Congratulations to all — talk about amazing.
Bah, #rubyonrails will be flooded with upgrade questions.
But it’s worth it!
When I change RAILS_GEM_VERSION to ‘2.0.0’ in my environment file, my app stops working
Not sure what to think about this – I can’t update!
rails -v reports: 1.99.0
gem update rails Updating installed gems… Bulk updating Gem source index for: http://gems.rubyforge.org Attempting remote update of rails Install required dependency activesupport? [Yn] Y Install required dependency activerecord? [Yn] Y ERROR: While executing gem … (Zlib::BufError) buffer error
GREAT !!!
Mike: The current version is actually 2.0.1. You may need to change other things as well, though. Depending on what version you’re moving up from.
48. Ray> same problem – it seems that activerecord 2.0.1 gem is corrupted
well done! lovin it!
I’ve been looking forward to this release. Any ideas on when the Agile Web Development for Rails (phenomenal!) book will put out a new revision with Rails 2.0? Thanks to the core team and all the hard-working contributors!
I’m popping the champagne! Good work guys! Mad respect to you!
Oh, cool! Good work guys!
Congratulations! Great work!
thank you! time for vodka :)
rails 2.0! too awesome.. dhh you rock!
Thank you Rails Team.
I go now to celebrate this on a corporate party, literally.
I have already updated to rails 2.0.1 since last nights 2.0.0. Who can ask for something more?
Outstanding!! I’ll present at the Rio on Rails event here in Brazil and my keynote is a full fledge Rails 2.0 presentation. I’m sure people will love the new features!! Congratulations to all the collaborators!
Woot!
I’m on windows and I get the same error as Ray. Zlib::BufError
Wow! I must have downloaded it just as it was uploaded as I couldn’t find a release announcement at 3pm GMT when I noticed the gems had been updated.
Well done guys!
Updated to Ruby 1.8.6 (backport from OpenSUSE 10.3 to 10.0 because of actionmailer.gem trouble) and downloaded Rails 2.0.0 this morning (on both Linux and Win2k). Great work!
One question regarding Rails 2.0.1 compared to 2.0.0 and 1.2.6: Is there a particular reason why “rails Demo; cd Demo; ./script/server” makes the default request “http://localhost:3000/rails/info/properties” hickup on MySQL? Why is a running MySQL database “Demo_development” actually required? This surely may follow later, but with 2.0.0 (and 1.2.6—) this worked without the fuzz.
Sweet! :) Congratulations!
Having been running edge rails exclusively for over 6 months, this is a very welcome release, and also a fantastic one. The core team really toed the line on keeping Rails lean and focused. Here’s hoping Rails 3.0 continues the same persistence of vision.
Andreas, the fix to that which was included in 2.0.0 caused other problems, so we had to yank it and do 2.0.1. We’ll get a better fix in for the next version, though. That info screen should be visible without a database configured.
Fantastic! , looking forward to all the new features.
Great work…. What is next on the roadmap?
I’m on Windows XP and got the same problem as Mike and Ray: gem update; Attempting remote update of activerecord; ERROR: While executing gem … (Zlib::BufError); buffer error
Congrats! Christmas is definitely a bit early this year!
Congratulations and tak, David!
Thanks a stack. Successfully installed ver 2.0.1 and changed RAILS_GEM_VERSION = ‘2.0.1’ in the environment.rb of my application, ran rake ails:update:configs but get 500 Internal Server Error after restarting Mongrel. Any advice is appreciated. Thank you…
Congratulations to everyone who worked on this!
Congratulations to David, the core team and all those people involved in getting this done!
An early and a really big xmas present! THANKS!
As DHH stated around comment 10, bug reports go at dev.rubyonrails.org. Any other issues should be directed to the excellent community in the forums and such. Not in comments here
Does CSRF protection work with forms that are fully cached?
Congrats & thanks for the hard work!
Upgrade was relatively painless for me but one thing gave me troubles that I haven’t seen mentioned before: a space is now encoded as %20 instead of + so anyone who has bookmarked a link to my site with a space in it gets a 404. (Also hardcoded urls in your app would fail, but you shouldn’t have those anyway)
It’s relatively easy to fix by putting an appropriate gsub in the affected models but I just thought I’d mention it here so people are aware. (BTW: if you use Apache as a load balancer, the mod balancer changes + to space before passing it on so that solves it too)
And on Pearl Harbor day, too ;-) Was that your ominously ironic intention? I would think that Rails has made a mighty splash already. In any case, this is great news.
gonzo, no. the form has to have the key set on a per session basis.
Sweet. Is there a simpler way to customize primary keys?
auto-incremented primary keys is the Achilles heel of rails/ActiveRecord.
Finally!! :D Congrats David!
@Archie Smuts
-open the config/environment.rb - inside the structure: Rails::Initializer.run do |config| put: config.action_controller.session = { :session_key => “_myapp_session”, :secret => “write smth here with at least 30 characters” }end
Hoozah! Great work guys!
Thanks a lot :)
Under Win XP Zlib::BufError with rubygem 0.9.2
No problem with rubygem 0.9.5
Great work guys!
If you are on windows and are getting the (Zlib::BufError) error run the following:
gem update—system
and then try again.
Great job guys, once again.
Keep up the good work!
Thanks Diego! That fixed it.
祝贺,move to 2.0
庆祝rails更新到2.0
congrats, you guys rock ;)
hello
Fantastic work! Thank you so much for pushing this and making it better. The one downside to all of this hard work is it makes it harder and harder to use another language / framework to create web applications.
D:\Downloads>gem install activerecord-2.0.1.gem ERROR: Error installing gem activerecord-2.0.1.gem[.gem]: buffer error
great job guys! it’s really impressive for me to have the new version of the world greatest web framework.
I literally picked this evening to start learning RoR. It looks l like my timing was perfect! What a gift to learn Rails using the newest version!
Congratulations to the entire team!
./script/plugin install auto_complete_field Plugin not found: [“auto_complete_field”]
Where can I find the new plugins? Any svn repository to find these?
Hail Rails 2.0! Now So RESTful and sexy. I want to try it before i give a praise. Good work Rails Team and DHH.
Never mind [#98], figured out where the plugins are:
http://svn.rubyonrails.org/rails/plugins/
I should have listened to the deprecated warnings before :D. It took me a couple of hours and a couple of bug fixes in acts_as_rateable etc, but my rails site is up and running.
Awesome work guys, now to understand the new cool stuff and implement them.
Thanks for this great framework. Yewoh ( www.yewoh.com) wouldn’t have been possible without rails.
Thank you so much !!!
A eagerly awaited release for us.
we have over 15 projects, which need to be ported from Rails 1.1.x and 1.2.x
excited to see the features which have finally made into 2.0
atlast a 2.0 framework for building 2.0 apps.
lot of work for other frameworks for doing a catchup
Senthil
does anyone knows if ruby 2.0 will also be released before new year?
Thanks for all your work DHH+team… really looking forward to several of the new features. best.
Great! I can’t wait to try it out. Thank you to everyone behind RoR. Because of this incredible piece of work that RoR is, developing web applications is one of the things I enjoy the most in my life. That’s quite something.
It wasn’t updating for me. Gave some ZLIB related error.
I updated RubyGems from 0.9.2 to 0.9.5 (current) and all is now well.
Just FYI.
congratulations! truly amazing, through and through! thanks for the kickass work!
:great => :thank you
I also would like to thank you and the core team for doing such a nice work. In four years, you and 37signals have become one of the greatest player of the web. You did with Web development what Apple did with OS, not only developing the best product but giving best practises. Rails definately changed my life. Thanks. Seb, Paris
I would like to thank the community and core team for making this possible.
You guys bring the fun and saneness back into web development with this wonderful framework.
I don’t know where I’d be without you guys today.
Keep up the very greatest work.
Xaxa. Thanks you’re a star. Ruby on Rails Rules
Mike and all those associated with the project-Great job done! Keep up with your good work.
Rails rocks…
-Anita CM
Congratulations on another awesome release! Onward and forward to world domination _
All want/need a new rails 2 official book! AWDWR now is a little outdated.
Congrats Rails core team developers and everyone that has contributed to this release of a great web framework!
恭喜恭喜
love rails forever
This was quite a long wait. But I think the wait was quite worth it. However just a point of concern on the scalability front. Will this scale better than the earlier versions. Has any body done some bench marking. Will appreciate if any one has this data and willing to share.
A big “bravo” to the whole Rails core team for this amazing work offered to the community !
Very nice! hacker.com.br will reborn in Rails 2.0
First, Congratulations! You’ve really set the bar higher once again, for software that is opinionated, but not in hard to understand ways.
Second, I know that you’ve got some of the absolute most humanistic API docs in the world, because I’ve read many others’ API docs that were just turn-offs. But of course, the big question remains, when will we see the books pouring out on 2.0? I saw that Obie’s book, The Rails Way, has finally hit the shelves and I guess it was delayed to include 2.0 stuff, but, it’s a bit on the too heavy to practically carry around with me side of computer books.
Third, how does 2.0 play with Ruby 1.9? It is most definitely coming out soon and has huge changes in it that will already require some work.
Fourth, as in my second note, there should be some effort to make sure that all the Rails tutorials out there online, that get high Google rankings, get pushed to be updated to something closer to 1.2.6 or even 2.0 This effort would do well to cut down traffic on the Rails Talk list. Just imagine how many broken experiences people are going to complain about… no use being a Vista or Leopard…
Fifth, which brings me to OS X 10.5.x in particular, push Apple to roll out upgrades to Rails (and Ruby) within their Software Updates. This will help prevent any languishing system versions that are woefully behind. They’re getting better at being responsive to developer requests! Laurent Sonsonetti is one of the guys over there that can be a real good person to talk to.
Hey, i wish i could be happy, but i can’t.
The ? methods on database columns stopped working.
blah.public? returns true if the column value is “f”.
Is this a planned behaviour? I guess this doesn’t only break my app :(
Thank you very much for delivering the great things we love to use.
‘rake doc:rails’ failed for me. Am I doing this all wrong in 2.0? Here is the error:
rake aborted! Don’t know how to build task ‘vendor/rails/railties/CHANGELOG’
(See full trace by running task with—trace)
Regarding my comment #122 the following tests:
require File.dirname(FILE) + ’/../test_helper’
class UserTest < Test::Unit::TestCase fixtures :users end
It passes in 1.2.6 but fails in 2.0.1
I think that should not be as this features is “advertised” in the rails book.
up-to-date rubygems (0.9.5) is required to install rails 2.0.1 on Windows XP – it would be good to add this info as another note to the end of the article
Wanderous!good jobs!
If you are getting (Zlib::BufError) buffer error, your gem installer may be out of date. E.g.,
gem update—system
gem install rails -y—source http://gems.rubyonrails.org
Congrats! Very nice improvements indeed. Very happy to hear about extracting the commercial database plugins. I’m all in favor of getting them on their own release schedules. Should help free up some of your cycles to work on core functionality as well. That’ll be good for everyone.
hi, first of all, thanx for the great update!
After updating to rails 2.0.1 the mysql gem, I installed successfully, doesn’t seem to work…
here’s the message when I start the server: WARNING: You’re using the Ruby-based MySQL library that ships with Rails. This library is not suited for production. Please install the C-based MySQL library instead (gem install mysql).
Any comments appreciated.
hi, first of all, thanx for the great update!
After updating to rails 2.0.1 on leopard the mysql gem, I installed successfully, doesn’t seem to work…
here’s the message when I start the server: WARNING: You’re using the Ruby-based MySQL library that ships with Rails. This library is not suited for production. Please install the C-based MySQL library instead (gem install mysql).
Any comments appreciated.
Excellent work guys. I love this framework and will be looking forward to getting my hands on it next year. Getting married in December so I won’t have time before then!
Good job!
Thanks to everyone! I’ll be looking to port my work over to 2.0 soon but I’ve hit some roadblocks:
Release announcement gives this example:
map.namespace(:admin) do |admin| admin.resources :products, :collection => { :inventory => :get }, :member => { :duplicate => :post }, :has_many => [ :tags, :images, :variants ] end
however :has_many doesn’t appear in the api documentation.
I tried rake rails:freeze:edge and got this error:
A vendor/rails/activesupport/MIT-LICENSE A vendor/rails/activesupport/README Exported revision 8333. svn: URL ‘http://dev.rubyonrails.org/svn/rails/tags/rel_2-0-1/actionwebservice’ doesn’t exist
Rails is for fags.
Real men code Fortran77
gr8 job, i am a big RoR lover.
Great job guys!
Just an information about migrations.
will t.timestamps create both created_at and updated_at? And for _on ? t.datestamps? and if i want to create just one of them?
t.datetime “created_at” ?
i forgot another thing… about the HTTP Basic Authentication. in the code example there are both username and password set on the top of the class: USER_NAME, PASSWORD = “dhh”, “secret”
authenticate_or_request_with_http_basic do |user_name, password| user_name USER_NAME && password PASSWORD end
and in the method you check if are equals. with a user model everything will be something like this?
authenticate_or_request_with_http_basic do |user_name, password| user = User.find_by_nick(user_name) user && password == user.password end
(ok, in this case the password is not encrypted, but it’s just an example :) )
Last question, what changes with the normal authentication? is it better using this by http? why?
thanks :)
action_controller\cgi_ext\query_extension.rb
Method initialize_query Sets @params = {} and cgi.rb don’t have access to params. It was useful to pass via post session_id now cgi[‘key’] won’t works.
yes, this is better, I still think you should look into Gluon http://mdp.cti.depaul.edu for some new ideas.
Thanks a lot for making programming enjoyable!!!
David,
You mention that the cookies are “in a hashed form that can’t be forged”.
Why should I believe you?
Since “forged” is a rather vague word do you mean collision resistant, pre-image resistant, or 2nd pre-image resistant?
I haven’t glanced at all the code yet so I’ll assume your using some version of SHA-2 and are aware of the collision vulnerabilities in MD5 and (the more difficult to generate) collision vulnerabilities in SHA-1.
Even so, “can’t be forged” sounds like snake oil, and is incontrovertibly incorrect (given enough time and enough parallel FPGAs).
WTG! Thank you so much for your contribution to software development. Our business wouldn’t exist without your efforts.
Alexander Muse Big in Japan
Sweet , I will upgrade as a soon as I can , can’t wait to take advantage of that new Ruby/Railsy Goodness (yes…apparently rails is also an adjective … who knew ?)
HAVE THEY DONE ANYTHING ABOUT SLOW AS 4 SNAILS STUCK IN SALT PERFORMANCE YET? OR DID I MISS IT IN THE CHANGELOG?
Congrats & thanks! Super excited about the new features & extra Rails goodness in general :)
Thanks to everyone! DHH’s Rails framework is very fascinating. My programming lifestyle has changed. Ruby on RAILS has now become so matured that it gives confidence to all the stakeholders.
thanx!!! i just got into Ruby and it’s great to know there is so much support around it.
I’ve tried updating rubygems, just updating rails…nothing is working. I am jumping back and forth between 404 errors and permission denied messages.
I’m trying to upgrade from 1.2.5 to 2.01. Anyone else having problems?
thank you for the new realease
Can we get someone that knows about scaling rails over here…
too much traffic here for RoR? Geez.
hey david.. why don’t u split the entire rails package into 2 sets: 1 will be ruby scripts and other things, and 2 will be platform dependent and optimized code, can can be compiled by the user on his/her machine.
we need a way to find the pieces that are called frequently and so, need to be optimized.
i love rails.. but it’s slow.
Yipppeeee!!!!
Yay ! , thanks
this is super! thx.
Good work, thanks
thinks
I have updated NetBeans 6.0 to use Rails 2.0.1, and now I can’t create new rails projects, as just one folder “RSpec” appears”... anyone knows how to solve this?
Faster. Leaner. Better. How great is that?
Thanks, all!
thaaankkkk youuuuuu ^^
Whenever i try to run the server up i get this:
`require_frameworks’: no such file to load—openssl (RuntimeError)
It has something to do with the initialize process and mentions something in my environment.rb file but i cannot see where i am requiring any such thing.
What would cause this error??
TOTALLY BONER! you all rock
Django is much better
Gracias amigos
You suck.
and I prefer Ruby over Python any day.
Help, I can’t run the mongrel, im using windows. After I upgrade it to 2.0 mongrel gives me an error. something about “gem_original_require”
So with the ActiveRecord serialization xml, how come its not possible to do something like:
class Couch < ActiveRecord::Base serialize :form, Couch end
and store an xml version of the object in the database? When I pass in a couch object, or eventually just self, it returns nil when I reference object.form.
Cheers! Matt
Do uploads still block?
WARNING:
Zlib::BufError, and rubygems “gem update—system” on Windows.
Please read this before updating rubygems to 0.9.5 on windows—it made my mongrel crash.
http://justaddwater.dk/2007/12/09/rails-20-gem-install-windows-mongrel-trouble/
Just wanted to write down some of the problems it caused me and how I solved it.
This may be a stupid question but when I just upgraded to 2.0.1 and when I run “rails newapp” I get “undefined method `camelize’ for app” error message
gdfgdfsgdsfgdfgf
Thanks for that great work!
Great work guys! I’ve been looking forward to using this!!
rails really fun!!!
I’ve been on “edge” for a long time waiting for this. Thank guys.
Are doubles not sexy?
create_table :purchases do |t| ... t.double :amount ...
undefined method `double’ for #<activerecord::connectionadapters::tabledefinition:0x25e2468>
I believe I used to be able to say
t.column :amount, :double
I love the timestamps call though, DRY as it gets.
I can’t wait to see how all the new stuff works. Great Job!
Wow! I’m very pleased to hear the good news
thanks god, rails 2 has finally been released.
Thanks, can’t wait to dig into all these new features!
Why does the rubyonrails.org and weblog.rubyonrails.org initial pages take so long to load? Both clocked in around 76 seconds as reported by the YSlow firefox plugin( and me watching the spinner in firefox go round while the page was blank )?
Oddly, once past either of those pages, things are much quicker( relatively. I am still getting average page loads around 6-10 seconds ).
How to implement Active Resource on the server side?
and Ruby owns, Python sucks
Great news – you rock! Hope to see it running on Ruby 1.9 for christmas :-)
Sorry, of topic,
but I am looking for an Web Content Management System based on Rails. It seems that radiant (http://radiantcms.org/) is the best choice at the moment.
Do you have a quick tip about some CMS you are probably using?
(The site going to be managed is about 50 pages. The wiki entry http://wiki.rubyonrails.org/rails/pages/Ruby+on+Rails+based+CMS was not that helpful to me, ‘cause it mixes up php/rails cms and I am looking for a more specific hint.)
Thanks to all!
good job guys! newbie on rials, it’s really cool! like it!
Super! Great Work there :-)))
@ugo: [on 07 Dec 16:48: Session on the user-side ? WTF ?! It’s the worse idea I have ever heard.]
How do you like cookies…?
祝福_
Great job!
ROR is PERFECT!!
Two things to request – books on Rails 2.0 and update the presentations or screencasts on the rubyonrails site please!
Great Job, hope to use it all soon!
Excuse my ignoracity. Where can I find the clasic_pagination plugin? I’ve rounded up the usual suspects and none admits to knowing anything about it.
ABluz- It is here: script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination
I invite everybody to take a look at a screencast I’ve compiled yesterday. This is the classic Blog app built using Rails 2.0. I think it is the First Rails 2.0 full featured screencast around.
See it here
I can not wait to try it! thanks the great rails team!
Great Job~ 恭喜~ omeidedo~
I’d love to see more about the profiler…
Good job.. I will try on this new one soon..
Since two days I get
C:\Programme\ruby>gem update -y—source http://gems.rubyonrails.org
Updating installed gems… Attempting remote update of activerecord ERROR: While executing gem … (Zlib::BufError)
Yeaaaaaa!!!!!!! Thanks all!!
Likely dumb question: is this still edge? Why? It seems to me that a 2.0 release would be what it is. But then, I still don’t feel I understand the gem system totally. Can anyone explain? Thx. Ed
Great man,Great job!
期待很久了,真棒。well done !!
This is big! Hopefully my web host is going to support Rails 2.0 soon enough!
Migration successful! Note any of you out there using the Redhill plugins: you must be using their EDGE plugins to reap the benefits of sexy migrations. I would love to know exactly what timestamps will give you, though.
на кириллицу :)
@Ralf Klamma:
try this to update the included zlib-stuff:
`gem update—system`
then do `gem update` and `gem cleanup` (if you like a clean gem)
@Ralf Klamma:
try this to update the included zlib-stuff:
`gem update—system`
then do `gem update` and `gem cleanup` (if you like a clean gem)
I upgraded, created a brand new rails project, started the server, surfed to localhost:3000. So far so good. Click on “About your application’s environment” and boom! The server crashes.
dyld: NSLinkModule() error dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle Reason: image not found
Weak.
Very happy with Rails 2.0. It’s a work of art.
But how do you use the debugger with say a unit test?
ruby my_unit_test.rb
doesn’t seem to do it—unless there’s something seriously wrong with my test. :)
Thanks.
Very happy with Rails 2.0. It’s a work of art.
But how do you use the debugger with say a unit test?
ruby my_unit_test.rb
doesn’t seem to do it—unless there’s something seriously wrong with my test. :)
Thanks.
glad to hear that. rails 2.0! I cannot wait to try these new features!
Action Pack: Resources: map More yucky pluralizations?
run my code and find:
DEPRECATION WARNING: observer is deprecated and will be removed from Rails 2.0 See http://www.rubyonrails.org/deprecation for details. (called from D:/repos/rails_test/app/controllers/user_controller.rb:2)
why?
@Falk Pauser
Worked for me.
Thank you very much.
Ralf
Hello guys, after the success of the First Full Featured Screencast of Rails 2.0 I released early this week, I decided to write a Tutorial explaining the video – with a few new tidbits – in this 2 part series:
Rolling with Rails 2.0, Part 1 and Part 2
Enjoy!
Hello,
For people who are using InstantRails Package on Windows like me I’ve written an article about how to implement Rails 2.0 into your InstantRails, Click here to see it.
cant wait for Ruby 2.0 now :)
Just finished starting codes last week to find 2.0 installed on my web hosting today. Lots of tasks to clear! Anyway, thank you, DHH!
With all these comments this article has become a very very very useful resource. Hopping to see more, I have learned many things from these discussions. Thanks very much for sharing.
Either a new book needs to be released or a documentation team needs to be assembled. Many of us cannot rely on this posting as a reference for using the new features & enhancements in v2.
Great work! Love Rails and enjoy Rails. Thanks very much.
C:\>rails -v c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:377:in `report_activate_error’: RubyG em version error: activerecord(1.15.3 not = 2.0.1) (Gem::LoadError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:309:in `activate’ from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:335:in `activate’ from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:334:in `each’ from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:334:in `activate’ from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:76:in `active_gem_with_o ptions’ from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `gem’ from c:/ruby/bin/rails:18
C:\>
@AnySuggestions?: gem install activerecord
It would be very nice, if you’d update the Wiki / Screencasts section a bit. There are some major changes in version 2.0 so that most of old tutorials aren’t compatible. That’s not nice for any newbie.
For example, I’ve checked out the linked “Build a secured web app with RoR” (http://sonjayatandon.com/05-2006/how-to-build-a-secured-web-application-with-ruby-on-rails/)—but well: doesn’t make fun to learn, if start_form_tag isn’t there anymore, f.e.
I updated to Rails 2.0 (on Linux) using:
$gem update rails—include-dependencies
”/people/1;edit is now /people/1/edit”
DHH – I remember you saying in a talk about resources that you put the ; syntax to discourage people from making non-crud actions. Why did you go back on it?
There is a litle bug when we use resources when controllers plural form == singular
like: news
see this ticked for details:
http://dev.rubyonrails.org/ticket/10513
awesome
congrats on the new release HOWEVER:
it sucks that old features don’t work anymore. I bought video tuts for ruby on rails on lynda, but scaffold doesnt work, so i’m stuck on section 4 and trow away my money on the video tut now :(.
DHH: I love you!!!!
WOW,i LOVE U
great job. rails in the enterprise, here we come. – JBH
so many error on my app. I will recovert
When your book will be updated? I wouldn’t buy the outdated one to learn Rails. Thanks a lot.
Scaffolds kind of don’t really work anymore. Could you give us a hint on what you have in mind? Like, updating the docs or the wiki. You can generate part of the scaffold by script/generate scaffold model_name, but before you could give it the controller name as well. It creates some views, but doesn’t seem to touch the controller any more.
Awesome job, and a great overview of new features.
[“If you can’t wait until the conclusion, here it is: yes. Go upgrade. In fact, I don’t have much to add to the already awesome and fairly comprehensive Rails 2.0 Overview from Ruby on Rails…”] (http://rubyisbeautiful.com/2007/12/18/time-to-upgrade-rails-2-0)
I’m still catching up on all of the documents, but in messing with the iPhone psuedo-mime-type from the example above, I think it should be Mime::Type.register_alias
Why did you choose to use the format “index.html.erb” and not “index.erb.html” Most html editors (like dreamweaver) know how to handle .html files but not erb file (unless you modify some files). It does not change a lot for me as i use textmate, but i think it makes more sense to have the mime type as the last of the extensions, and not the renderer.
awesome!! You guys did a great job!! Thanks so much!!
Congratulations to everyone involved! I feel great being a member of this amazingly progressive community. The era of doubt about Rails is long past.
Frohe Weinachtwünsche von Deutschland!
I love you DHH!!!!
Thanks for all the hard work and thought that you’v put in this version.. תודה
Wow I reinstalled Rails, and tried a quick scaffold, and wondered what was going on. Turns out that I have Rails 2.0 ! – After a bit of Googling, have some idea of the new Scaffold, and got my basic RAILS Apps up and running. Pretty daunting without a decent book on the subject. The first author to get a decent Raile 2.0 book out there will be well rewarded. Shame about your closed stance on ActiveWebService and SOAP though.
Merry Christmas to Everyone !
Jules
I have created a screencast that shows how to use scaffold in Rails 2.0.
http://bparanj.blogspot.com/2007/12/rolling-with-ruby-on-rails-revised.html
It is the cookbook app published on onlamp.com “Rolling with Ruby on Rails”.
tanks DHH
Those who want the Rails 2.0 version of the depot app in the AWDwR, get the screencast here:
http://www.rubyplus.org/episodes/19-AWDR-Depot-App-using-Rails-2-version.html
What is your ruby version and the gem version ? I can’t run Rails 2.0.2 with ruby 1.9.0 . Thank you .
Bala’s screencast is probably helpful, but was also 200MB, so I didn’t actually watch it.
Short explanation: “scaffold :model” is no longer put in the controller, it’s now an option to the generate script.
Long explanation + example: http://davidlynch.org/blog/2008/01/rails-20-scaffolding/
It might be awsome, great etc.. for those of you who are ahead in Rails but certainly it is a nightmare for someone like me who just started learning Rails and who is following tutorials written for older versions. I did not master generating scaffold and migration and here I learn that rhtml is no more in use, and that t.column is being replaced by t.references and much more. What I don’t like about Rails is the fact that it is not well documented. Many times I did searches about error messages that I got but in vain. I love Rails, I want to be proficient in it. Please give me advice how to progress without being frustrated for I thought the essence of Rails is to prevent programmers’ frustration in the beginning. Thank you.
@Zangra
You might want to use Rails 1.2.6 since, as you mention, Rails 2.0 isn’t going to be as well supported when it comes to following tutorials or doing Google searches.
I was able to do this by entering the following via the command line (from your project directory [rails/project]):
rake rails:freeze:edge TAG=rel_1-2-6
That will put Rails 1.2.6 in your vendor directory and your project will use that by default.
It’s pretty unfortunate that map.resource :has_many => [], map.resource :has_one => [], and assert_difference are mentioned as neat new things but are not actually listed in the 2.0 docs.
Thanks Wayne for your reply. I did what you said and got this error message: ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Rails. I will do some search on this issue and hope will find a solution. For the new scaffolding I think I begin to see the philosophy behind it: Instead of creating a model, a controller, views and a migration separately as in the old versions of Rails, the new scaffolding allows to do all these in one shot from the very start and I find it good (what a rewarding for the ego!). My naive vision is that Microsoft is what it is now simply because it offered tools to the common of the mortals something like the philosopher Sartre did in philosophy. Before him philosophy was a matter discussed between philosophers in closed private clubs. Sartre threw it in the street to be accessible to the layman. Same thing goes for linux. It’s no more a hassle to install it as it was in the early years. It belongs to to the layman now. A big thanks from a layman.