Working with multiple ruby versions
For a while, I’ve felt an itch to experiment with Ruby 1.9. It would be better to use it in our day-to-day work, but Ruby 1.9 isn’t that far yet. What has hold me back until now, is that I don’t want to make an unstable Windows machine out of my Maccie. It’s my primary workstation, and I have to work on it constantly.
Via Dr Nic I found Working With Multiple Ruby Versions Has Never Been This Easy.
With the help of the RubySwitcher script, it is laughingly easy to use several Ruby versions next to one another. There’s no more excuse not to do it.
Out of the box, you can install and use the following versions of Ruby:
install_ruby_191(install)
use_ruby_191(use)install_ruby_186(install)
use_ruby_186(use)install_ruby_187(install)
use_ruby_187(use)install_jruby(install)
use_jruby(use)install_jruby_120(install)
use_jruby_120(use)install_ree_186(install)
use use_ree_186(use)
To use the standard Ruby version: use_leopard_ruby
i18n and Rails Engines
Rails Engines, what are they? What do they do? But most importantly: how do they do it?
Rails 2.3 brings us much of the same functionality as the Rails Engines plugin. Learn how to embed one application into another in this episode.
Engines allow us to use one application in another in the form of a plugin. As the screencast shows, you can integrate the app folder of a Rails application in the plugin of another one. All models, controllers and views are available. If you still need custom functionality, you can add them in your applications ‘own’ app folder by redefining the model, controller or view. The same goes for routes; if you have routes.rb in your plugin dir, it is loaded as well.
And i18n, how about that? You would expect config/locals/*.yml to work just as nicely as the app dir and routes.rb. But it doesn’t.
Luckily, it’s not that hard to solve:
In environment.rb, you add
config.i18n.load_path += Dir[Rails.root.join('vendor',
'plugins', 'your_plugin', 'config', 'locales',
'*.{rb,yml}')]
If you prefer to read the Railscast: ASCIIcasts - 149: Rails Engines
Generating a timestamp string in Ruby
In the hope that the Google Gods will help me next time I need this :-)
An easy way to generate a human-readable timestamp string, following the ISO 8601 standard, is:
Time.now.utc.iso8601.gsub('-', '').gsub(':', '')
Very handy if you need a timestamp in a file you’re writing.
Moved!
We‘ve moved today. Closer to our homes, and that was necessary. You can now better reach us, and that was even more necessary. The fact that the office is nice, is a great plus :)

From now on, you can find us at UBCA for custom software and web application development, iPhone development, Ruby and Rails contracting, or just to drink a coffee.
Roleify, a Rails authorization plugin
Today I’ve pushed a few updates to the Roleify rails plugin.
The changes are
- you can now use ‘namespaced’ controllers
- I added a helper method to hide/show blocks for a specified role
Example
The initializer
Roleify::Role.configure("role_a", "role_b") do
{
:role_a => { :dashboard_issues => :all },
:role_b => { :issues => "index" }
}
end
So, role_a refers to a Dashboard::IssuesController and role_b refers to an IssuesController.
The helper
module ApplicationHelper
include Roleify::RoleifyableHelper
end
The view
<% allowed?(Roleify::Role::ROLE_A) do %>
// whatever you want for role_a eyes only
<% end %>
More info on GitHub.
- Page 5 of 6
- Newest articles
- Newer articles
- Oldest articles
- Older articles
