What you copy may not be what you see in the browser. Here is an online tool to determine the...
Say you want to allow users to emphasize some string, but the whole markdown thing would be far too much...
yaml4r is a juxtaposition of yaml documents and their Ruby couterpart. Thus, it does a great job as YAML-doc...
Sometimes you might want to limit the number of associated records in a has_many association, but cannot add a...
Ever wondered about the difference between def and define_method? Turns out there are three implicit contexts in Ruby. def...
The way Rational#to_s works on Ruby has changed from Ruby 1.9 on. Here is how to get the...
When a controller action redirects to an external URL (like http://somehost.com/some/path) you will find that this is hard...
Unfortunately, Capybara does not offer a switch to disable cookies in your test browser. However, you can work around that...
To set a cookie in your test browser for cucumber tests, you need to know which driver you are using...
In Ruby, the meaning of protected and private is different from other languages like Java. (They don't hide methods...
Access the Method object Dead simple: Get the method object and ask for its owner: "foo".method(:upcase) # => #
Rails flashes (FlashHash) track a list of used keys, which is not respected when comparing flash hashes.
For example if you use rvm and get this message: ERROR: Loading command: install (LoadError) no such file to load...
Consider this class: class Foo private def test puts "Hello" end end While you can say create a block to...
Do not pass times to date attributes. Always convert times to dates when your application uses time zones. Background
Ruby 1.8 (supplied by Rails' ActiveSupport) >> BigDecimal.new("0.1").floor.class => BigDecimal Ruby 1.9 (supplied by Ruby 1.9 itself) >> BigDecimal.new("0.1").floor.class...
Rails understands a :limit options when you create columns in a migration. Its meaning depends on the column type, and...
When you use heredoc, string interpolation is enabled by default: x = "Universe" <<-MESSAGE Hello #{x} MESSAGE # => "Hello Universe"
Sometimes it seems a favicon does not work because your browser displays an old version or (in case of local...
When MySQL refuses to use your index, there's a number of things that you may be doing wrong. One...
tl;dr: Do not use merge! for session hashes. Use update instead. Outline Let's assume you're modifying the...
JavaScript has no built-in functions to compare two objects or arrays for equality of their contained values.
Watch out when saying something like 1.year in Rails. The result is not a Fixnum and can cause unexpected errors...
In Ruby 1.9, instance_eval calls the block the with receiver as the first argument: In Ruby 1.8, receiver.instance_eval...