makandra dev

If you want to rename a key of a Ruby hash, this could help you out. Just put it into...

github.com

delocalize provides localized date/time and number parsing functionality for Rails.

First of all: You could just use RVM which would make the pain go away. If for some reason you...

github.com

You can use the whatlanguage gem to detect the language of a Ruby string. Note that it also has not...

Expiration of Rails sessions By default Rails sessions expire when the user closes her browser window. To change this edit...

When submitting textareas, browsers sometimes include carriage returns (\r) instead of just line feeds (\n) at the end of each...

If you iterate over a collection of arrays, you can destructure the arrays within the block parameters: movies_and_directors...

Since RubyMine 3.1 you can drag tabs across panes/windows and out of the main window to create new windows.

makandra dev

There are two distinct ways of commenting Haml markup: HTML and Ruby. HTML comments This will create an HTML comment...

makandra dev

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...

Rails 3, 4, 5, 6 config/application.rb config/environment.rb before the initialize! call (we don't usually edit this file)

The state_machine gem ships with a scope with_state. This scope has some problems in complex queries or scope...

makandra dev

Update RubyGems and Passenger Bundler requires Rubygems >= 1.3.6. Run gem update --system if you have an older version.

Sometimes you want to fetch associations for an ActiveRecord that you already loaded, e.g. when it has deeply nested associations...

github.com

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

One option is to use partials. Or you can set the @template field to the name of another action:

Sometimes files attain executable-flags that they do not need, e.g. when your Windows VM copies them over a Samba...

When you create e.g. a sidebar box that contains headlines and paragraphs, the final paragraph's margin in that box...

When you need to add a event listener to hundreds of elements, this might slow down the browser. An alternative...

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

Don't use should validate_format_of(...) because that matcher works in weird ways. Use the allow_value matcher instead...

Use this if you want to show or hide part of a form if certain options are selected or boxes...

rjb.rubyforge.org

rjb is a bridge software. It connects Ruby and Java.