Automatic Flushing: The Rails 3.1 Plan « Katz Got Your Tongue?
This post explains, in some detail, how we will implement a nice performance boost for Rails developers. Understanding the details might help gain the full benefits of the optimization, but you will gain some benefits even if you have no idea how it works.
The Rails Internationalization (I18n) API
This guide will walk you through the I18n API and contains a tutorial how to internationalize a Rails application from the start.
Translations available in rails
YAML List of all translations currently available in Rails
Rails 2.3 Nested Object Forms: I’m not Crazy about Them « SmartLogic Solutions Blog
I just finished reviewing Rails 2.3 Nested Object Forms. While a very nice and “magical” feature, I’ve got to admit that I’m really not that crazy about how it works.
Rails plugin testing guide
This article is an introduction to testing Rails plugins.
The Bark Blog » Testing Rails Model Plugins
Unfortunately, by default plugin tests are pretty bland. They use the plain unit test suite supplied by Ruby, and not any of the extended Rails test framework. This will leave our plugin’s test classes with no access to fixtures, database.yml configuration, or any of those nice class auto-loading features.
svenfuchs's rails-i18n at master - GitHub
Central point to collect locale data for use in Ruby on Rails.
paperplanes. run_later Gets Some Rails 2.3 Middleware Love
In earlier version I needed to do an awkward thing that only affected development mode, where Rails unloads all classes after each request. run_later runs code in a separate thread, and depending on how long that code runs the classes would be unloaded when they're still accessed from the worker.
Rails Envy: 6 Reasons to use Webbynode
Webbynode is a very affordable VPS host (256 RAM for $15) which has great support for Rails applications.
Codaset // joelmoss / Rails Concerns
Concerns is a simple Rails plugin that provides you with a simple way to organise your Controllers, Models and Mailers, and split them into smaller chunks of logic. It is especially useful when you have lengthly models, and you get fed with having to scroll through several hundred lines of code.
has_many :bugs, :through => :rails: Active Record Query Interface 3.0
So here’s an overview of how things are going to work in Rails 3.
Rails 2: Calling instance_eval on a scope will trigger a database query
In Rails 2, when calling instance_eval or instance_exec on a scope, the scope will fetch its records from the database.
This has been fixed in Rails 3+.
Disable Rails XSS protection in ActionMailer views
This might eventually be fixed by Rails itself.\
Right now this is the way to have the rails_xss plugin not escape the body of ActionMailer mails.
Put this into config/initializers/mailers_without_rails_xss.rb:
Get compiled code of a view template in Rails 4.2
If you want to inspect the compiled code of your erb (or haml) templates, you can run the following code in your view or your controller:
template = lookup_context.find_template(action_name, lookup_context.prefixes)
template.handler.call(template.refresh(self))
The output will be something like
@output_buffer = output_buffer || ActionView::OutputBuffer.new;@output_buffer.safe_append='My template
'.freeze;@output_buffer.to_s
Turn off SSL for scenarios with Selenium
Selenium does not speak SSL because it uses WEBrick that doesn't. When you use Selenium for Cucumber scenarios that visit pages with SSL, they will fail.
To turn off SSL only for scenarios that are executed on WEBrick, put this method into your application controller.
def ensure_proper_protocol
request.headers['SERVER_SOFTWARE'].andand.include?('WEBrick') || super
end
Rails always tries to use a layout with the same name as your controller
If you have a FooController and also have a layout app/views/layouts/foo.html, Rails will use this without being told so.
This is super convenient except never.
Active Record and PostgreSQL — Ruby on Rails Guides
Rails guide that covers PostgreSQL-specific column types and usages for Active Record.
You should especially keep in mind the special datatypes that PostgreSQL offers. \
Types like json and array take away a lot of the pain that you had on MySQL projects.
Example use cases for array are tags or storing foreign keys (instead of a join model). You can even index them.
Ruby on Rails 4 and Batman.js
Batman is an alternative Javascript MVC with a similar flavor as AngularJS, but a lot less features and geared towards Ruby on Rails.
The attached link leads to a tutorial for a small blog written with Rails / Batman.js.
I'm collecting other Batman.js resources in my bookmarks.
Rails jQuery UJS: Now Interactive
We can now plug into every facet of the Rails jQuery UJS adapter, binding to custom events, and even customizing internal functions, without hacking or monkey-patching the rails.js file itself.
Rails 3 Remote Links and Forms: A Definitive Guide
Thanks to habits engrained by Rails 2’s link_to_remote and remote_form_for, we expect that Rails 3 would also handle the AJAX response for our remote links and forms. But it doesn’t; it leaves that for you.
The dangers of url_for in Rails applications
In a great post about named routes in Rails, path vs. url, Viget Labs ponders which variant is best used.<br />
<br />
Most often we use foo_path, which when used in Rails URL helpers will generate a relative path, where foo_url generates a full URL. In most cases the path makes most sense, but not always.
Rethinking Rails 3 Controllers and Routes | Free PeepCode Blog
The Rails router has been written and rewritten at least four times2, including a recent rewrite for the upcoming Rails 3. The syntax is now more concise.<br />
<br />
But never mind making it shorter! It’s time for a final rewrite: Let’s get rid of it altogether!
BlogFish: Ruby on Rails Security
Recently I've been made aware of people inside US Government organizations using my Ruby on Rails Security presentation as an excuse to limit Ruby on Rails adoption and projects inside those organizations.