This returns the name (including path) of your current layout: response.layout => "layouts/admin" # inside views that are using the 'admin' layout...
When using form_for you can give the form's target URL either as a string or an array:
The ancestry gem allows you to easily use tree structures in your Rails application. There is one somewhat unobvious pitfall...
If you want to see how long your database queries actually take, you need to disable MySQL's query cache...
Even when you're using bundler, it might be significant in which order your gems are listed in your Gemfile...
This post will describe how I stumbled upon a code path in the Linux kernel which allows external programs to...
A good tool to generate strong passwords and secrets is "apg". You can get it with sudo apt-get install...
If you need to call a state_machine event and do not want to re-define resource_controller's create...
Both these approaches will keep your GET parameters -- and will only work for GET requests. Capybara: When /^I reload the...
In /etc/crontab In /etc/cron.d/* In /etc/cron.hourly/* In /etc/cron.daily/* In /etc/cron.weekly/* In /etc/cron.monthly/* In the personal crontab of any user. This...
You can use record.send(:update_without_callbacks) or record.send(:create_without_callbacks) This can be used as a...
With its you can switch the subject of an example to a method value of the current subject: describe Array...
Find conditions for scopes can be given either as an array (:conditions => ['state = ?', 'draft']) or a hash (:conditions => { 'state' => 'draft...
When Paperclip attachments should only be downloadable for selected users, there are three ways to go. The same applies to...
This will show you how to create a RSS feed that the Feed Validator considers valid. Note that RSS is...
You should test the callback methods and its correct invocation in two separate tests. Understand the ActiveRecord note before you...
Be careful! The following solution will delete files on a volume. If you don't know exactly what you're...
In a great post about named routes in Rails, path vs. url, Viget Labs ponders which variant is best used...
The following Haml will do: %head{ :profile => 'http://www.w3.org/2005/10/profile' } %link{ :href => image_path('favicon.ico'), :rel => 'icon', :type => 'image/vnd.microsoft.icon' }
This is an awesome gadget in your toolbox, even if your test coverage is great. gem install ruby-debug (Ruby...
To return non-HTML responses (like XLS spreadsheets), we usually use the respond_to do |format| format.xls do # send spreadsheet...
If you added a file by mistake, you can unstage it (but keep local changes) by saying git reset HEAD...
There are three ways to define your own RSpec matchers, with increasing complexibility and options: 1) Use RSpec::Matchers.define
You may omit the /path/to/link_name to have a link with the same filename appear in the current directory