Generate a path or URL string from an array of route components

Posted Over 13 years ago by Henning Koch.

When using form_for you can give the form's target URL either as a string or an array:

MySQL: Disable query cache for database profiling

Posted Over 13 years ago by Tobias Kraze.

If you want to see how long your database queries actually take, you need to disable MySQL's query cache...

An obscure kernel feature to get more info about dying processes

Posted Over 13 years ago by Lexy.
timetobleed.com

This post will describe how I stumbled upon a code path in the Linux kernel which allows external programs to...

Generate a strong secret from the shell

Posted Over 13 years ago by Henning Koch.

A good tool to generate strong passwords and secrets is "apg". You can get it with sudo apt-get install...

Reload the page in your Cucumber features

Posted Over 13 years ago by Arne Hartherz.

Both these approaches will keep your GET parameters – and will only work for GET requests. Capybara: When /^I reload the...

Deliver Paperclip attachments to authorized users only

Posted Over 13 years ago by Henning Koch.

When Paperclip attachments should only be downloadable for selected users, there are three ways to go. The same applies to...

Create a valid RSS feed in Rails

Posted Over 13 years ago by Henning Koch.

This will show you how to create a RSS feed that the Feed Validator considers valid. Note that RSS is...

Remove resource fork files from a FAT volume on MacOS

Posted Over 13 years ago.

The following solution will delete files on a volume. If you don't know exactly what you're...

The dangers of url_for in Rails applications

Posted Over 13 years ago by Lexy.
emphaticsolutions.com

In a great post about named routes in Rails, path vs. url, Viget Labs ponders which variant is best used...

Debug Ruby code

Posted Over 13 years ago by Henning Koch.

This is an awesome gadget in your toolbox, even if your test coverage is great. gem install ruby-debug (Ruby...

Difference between respond_to/format and params[:format]

Posted Over 13 years ago by Thomas Eisenbarth.

To return non-HTML responses (like XLS spreadsheets), we usually use the respond_to do |format| format.xls do # send spreadsheet...

Defining custom RSpec matchers

Posted Over 13 years ago by Henning Koch.
github.com

There are three ways to define your own RSpec matchers, with increasing complexibility and options: 1) Use RSpec::Matchers.define

Setting expiry dates for images, JavaScript and CSS

Posted Over 13 years ago by Thomas Eisenbarth.

When deploying Rails applications you might have noticed that JS and CSS are not cached by all browsers.

Spec correct routing of custom URLs

Posted Over 13 years ago by Henning Koch.

When you roll custom URLs with hacks like routing-filter, you can put a spec like this into spec/routing/routing_spec.rb:

How Rails and MySQL are handling time zones

Posted Over 13 years ago by Tobias Kraze.

When working with times and dates in Rails applications, you need to deal with the following problem: In Rails, Time...

Change Paperclip secrets the hard way

Posted Over 13 years ago by Henning Koch.

So you screwed up and copied Paperclip secrets from one project to another. Here is a semi-automatic, painful way...

Marry Capybara with SSL-enabled applications

Posted Over 13 years ago by Henning Koch.

Capybara does not play nice with sites that have some actions protected by SSL, some not. A popular way to...

Faking and testing the network with WebMock

Posted Over 13 years ago by Henning Koch.
github.com

An alternative to this technique is using VCR. VCR allows you to record and replay real HTTP responses, saving you...

Submit a form with Prototype

Posted Over 13 years ago by Tobias Kraze.
prototypejs.org

For example, to send a form and populate a preview div with the response. $('content_form').request({ parameters: { 'preview': "1...

Rethinking Rails 3 Controllers and Routes | Free PeepCode Blog

Posted Over 13 years ago by Lexy.
blog.peepcode.com

The Rails router has been written and rewritten at least four times2, including a recent rewrite for the upcoming Rails...

stefankroes's ancestry at master - GitHub

Posted Over 13 years ago by Lexy.
github.com

Ancestry is a gem/plugin that allows the records of a Ruby on Rails ActiveRecord model to be organised as a...

Load all models into an Array

Posted Over 13 years ago by Arne Hartherz.

Dir.glob(File.join RAILS_ROOT, 'app', 'models', '*.rb').collect{ |path| path[/.+\/(.+).rb/,1] }.collect(&:camelize).collect(&:constantize)

Rails - Multi Language with Fast_Gettext

Posted Over 13 years ago.

sudo gem install gettext --no-ri --no-rdoc sudo gem install fast_gettext --no-ri --no-rdoc script/plugin install git://...

Automatically build sprites with Lemonade

Posted Over 13 years ago by Tobias Kraze.

See the lemonade descriptions. Unfortunately, the gem has a few problems: it does not work with Sass2...