Rush to Rails 1.2 Adds Tons of New Features 12

Posted by Bob Silva Tue, 05 Sep 2006 15:51:00 GMT

The Rails Developers are rushing to get a 1.2 release out the door before RailsConf Europe. I'll try to list a quick run down of changes you'll may not be aware of in 1.2:
  • Access nested attributes in RJS templates. Now you can use syntax like this: page[:foo][:style][:color] which will generate javascript like: $('foo').style.color

  • Michael Koziarski is my hero for this change. If you've ever tried to use a 'quote' column in your model, you quickly found out that it conflicted with AR's quote column method. No longer is this an issue. def quote has been changed to def quote_value

  • Calling image_tag without the file extension now raises a Deprecation warning. In 2.0, it will no longer append .png to the file name. This is welcome change, unneeded magic is well...unneeded.

  • UPDATE: This change has been reverted for the time being. Now you can access the locals hash directly. In your partials, you can check if a local varialbe was passed in by doing:
    if locals[:local_var] then ...

  • In 2.0, the default for foreign_keys will be the association name, rather than the class name. So if you specify a :class_name with no :foreign_key on your belongs_to associations, it will throw a Deprecation warning. The tests explain this pretty well:

    def test_deprecated_inferred_foreign_key  
      assert_not_deprecated { Company.belongs_to :firm }  
      assert_not_deprecated { Company.belongs_to :client, :foreign_key => "firm_id" }  
      assert_not_deprecated { Company.belongs_to :firm, :class_name => "Firm", :foreign_key => "client_of" }  
      assert_deprecated("inferred foreign_key name") { Company.belongs_to :client, :class_name => "Firm" }  
    end 

  • The Ruby/MySQL driver that ships with Rails has been updated to work with the new authentication in MySQL 4.1+. Of course, everyone uses the Ruby C bindings to MySQL right?

  • My own patch to distance_of_time_in_words was applied. What does this mean to you? Nothing at all, I just wanted to tell you about it.

  • Some nice additions to Prototype Element Handling. You can now traverse the DOM using the new Element.up, Element.down, Element.previous and Element.next methods. To make debugging easier, you can use Element.inspect. Check out the changeset for more useful changes.

    Examples:  
      <div id="sidebar">                   -> $('nav').up() or $('menu').up('div')   
        <ul id="nav">                     -> $('sidebar').down()  or $('sidebar').down('ul') or $('menu').previous()  
          <li>...</li>                    -> $('sidebar').down(1) or $('sidebar').down('li')  
          <li>...</li>                    -> $('sidebar').down(2) or $('sidebar').down('li', 2) or $('sidebar').down('li').next('li')  
           <li class="selected">...</li>    -> $('sidebar').down('li.selected')  
         </ul>                               
         <ul id="menu">                    -> $('sidebar').down('ul').next()  
    
    

  • Rails will actually use the 500.html thats been sitting in public for awhile when your application fails to catch an exception not related to routing.

  • In the testing department, assert_tag has been deprecated in favor of the new assert_select family of assertions.

  • Another one of my patches got applied. radio_button_tag now generates a unique id attribute based on the name_value pattern.

  • And plenty of other deprecation warnings throughout Rails...those you can figure out for yourself.

Comments

Leave a response

  1. Jeremy Voorhis about 5 hours later:
    My documentation fix was carried over as well - http://dev.rubyonrails.org/changeset/5016 - so rake -T will be slightly more useful now :)
  2. Joe Ruby about 6 hours later:
    image_tag automagically adding a png extension -- a long-standing annoyance. PS - Kevin didn't get "thrashed."
  3. Daniel Berger about 7 hours later:
    They're "rushing", are they? In that case, I'll wait for the inevitable, "We broke something, soon to be fixed in 1.2.1" release. ;)

    Are they adding the find_by helpers for foreign keys?

  4. Bob Silva about 7 hours later:
    Hi Dainiel, I'm not an authoritative source, but this is their typical release cycle. Let the feature/minor bug patches stack up, then go on a whirlwind spree to add the patches they feel are up to par, then shove out a release. And yes, it is probably best to wait for the 1.2.1 release.
  5. DHH about 8 hours later:
    Rails 1.2 final won't be ready by RailsConf. The best we can hope for is an RC.
  6. Bob Silva about 11 hours later:
    I figured as much, I saw the RC mentioned in #caboose, but didn't want to assume what your intentions were. To clarify on earlier comments, I don't see anything wrong with the whirlwind spree of commits. That's what test cases are for.
  7. Sebastian about 13 hours later:
    Great post -- and utterly free of controversies :). One thing not mentioned here are the recent changes to dependencies and reloading. David's announcement (http://weblog.rubyonrails.org/2006/8/11/reloading-revamped) can't seem to explain away some of the issues i've been having as a result of it; so it would be great if someone could give a good breakdown of these changes and their practical implications. Just thought i throw this out there, should someone be willing and able...
  8. Yan 1 day later:
    about the RJS, good effort but page[:foo][:style][:color] is kinda ugly, no? Why not page[:foo].style.color?
  9. Bob Silva 1 day later:
    You would need to ask Thomas Fuchs that question. I'm only the messenger.
  10. Chu Yeow 1 day later:
    "My documentation fix was carried over as well - http://dev.rubyonrails.org/changeset/5016 - so rake -T will be slightly more useful now :)"
    Great, thanks for fixing this Jeremy. I was a little confused while trying to add some custom test rake tasks when I noticed the task desc in testing.rake wasn't being used and (what I assume is) the default test task descriptions were being spit out by rake -T.
  11. Piggy 1 day later:
    Is it just me who see the code in your blog is embeded into a textbox twice? And I'm confused that you mentioned 'In 2.0' twice. Aren't they 'In 1.2'?
  12. Bob Silva 1 day later:
    Didn't realize PRE tags had special formatting in Typo. As for the 2.0 stuff, the deprecation warnings will exist in 1.2, the actual code changes will not appear until 2.0. At least, thats my understanding.
Comments