#137 Memoization
Nov 24, 2008 | 5 minutes | Performance, Rails 2.2
Rails 2.2 is out! In this episode I show how to upgrade Rails and then demonstrate one of the new additions: Memoization.
- Download:
- source code
- mp4
- m4v
- webm
- ogv
Sorry, but the video cannot be played under Windows/Linux neither with latest VLC, nor MP with codecs? Any word on new compression format being used?
Thanks.
Video works fine as always. Currently on my Ubuntu but I expect the same on my Xp. Nevertheless, I'll test it.
The subject is on the spot as we all tend to forget the little things that can easily speed up our application.
Dejan Dimic, you have to make sure your ubuntu can play restricted media. Google around on how to play media files.
Please, continue on railscasts about new features.
Especially *internalization*.
Thanks!
I'm using opensuse/gnome and can't watch the video in the browser. I must download and open with MPlayer.
Other .mov videos are shown well from other sites ...
After upgrading to Rails 2.2.2 from a 2.0.2 version I had to remove the following setting from my environment file (development.rb)
config.action_view.cache_template_extensions
The cache_template_extension has been deprecated in ActionView with the latest RoR release, so my server wouldnt startup properly.
Regards
another useful screencast, thanks Ryan! :)
For those having problems with the video, I'm hoping to add another compression option (non QuickTime) soon. I just haven't been able to get around to it quite yet. Sorry for the inconvenience.
@MTH internationalization is definitely one of the major additions to 2.2, and I will be covering it sometime in this series. :)
Ubuntu Hardy, can't play either format in any of my 5 video players. Up to this one, the 'alternative download' played more reliably, but I get video without sound on this one (with all 5 players).
I just built mplayer from subversion, and it does exactly the same thing.
Guessing at the content of the video from the show notes is not going to work for me. I wonder if the Peepcode videos will also give me trouble? I guess it's time to pay up and see.
EnvyCasts.com has a great video on Rails 2.2 features.
I was able to play the video under Ubuntu 8.10 using mplayer as long as I didn't resize to full screen (video went blank if I did). and if I paused it when I hit play again it started over from the beginning.
So, I think it should be made clear that the memoization feature of Rails only works -per- request, not over a span of multiple requests. Therefore, if you call the memoized function on one page, it will not be cached for the next page, or any future pages. This is really only useful if you have to call the same request over and over on a single page (read: partials), etc.
Also, keep in mind that Rails caches database requests automatically, so having a memoized method for anything relating to the database isn't really that useful.
Hope this helps someone! :) Thanks, Ryan.
Short, sweet, and as always - uber useful.
Thanks Ryan.
You're my GOD Ryan ! :)
i18n screencast in the near future, great ! ;)
i18n screencast would be great. AFAIK internationalization in rails will be useful only for titles, headers, some short phrases, rubrics... that is it is for translating interface, not the content of the page. Would be nice if smbd share what he/she uses for fully localizing the app.
I wrote a pretty extensive article about the whole topic of Memoization. Maybe this can be an additional source of information for some people: http://www.railway.at/articles/2008/09/20/a-guide-to-memoization (*shameless self-promotion*).
Really so great, a serie of screencast on Rails 2.2. :)
Wonderful stuff, had no idea it had been released until I stopped by here!
Thanks!
I have tested the video on my XX too and as expected it work like charm.
On my Ubuntu the Totem Movie Player(gstreamer) and on XP the QuickTime player without any problem can play this movie.
To repeat my self in this DRY community: The movie is working fine.
:-)
Does memoize :find_by_id work too?
memoize :what_are_we_eating
Many thanks for another useful screencast.
:)
Finally rails 2.2 released!
This is what I was waiting for :)
Hey Ryan thanks for all screencasts till yet!
I hope you will put more screencasts ASAP on rails 2.2
Wll test this one on my own, thanks
This feature was much needed. I liked the "@something ||=" idiom, but it didn't work well in situations that would set the instance variable to null. In those cases, it was kind of ugly to have to write "return @something if defined?(@something)" at the top of the method.
Video works for me embedded in Firefox on Ubuntu 8.10 after it installed some gstreamer plugins.
After doing update_rubygems on Ubuntu 8.10 I lost all my installed gems (gem list --local) although looking in /var/lib/gems/1.8/bin and .../gems I can see they're there.
Updating rubygems has always been a fun exercise, huh?!
Oh I see. It's because I was running as sudo instead of root and it's looking in ~/.gem now
The subject is on the spot as we all tend to forget the little things that can easily speed up our application.
http://api.rubyonrails.org/classes/ActiveSupport/Memoizable.html