stackoverflow.com

url = 'http://www.foocorp.com/foo/bar' URI.parse(url).host # => www.foocorp.com Note that this will raise an error if the given argument is...

In theory you can take any scope and extend it with additional joins or conditions. We call this chaining scopes...

ActiveModel::Errors is used to handle validation errors on Rails objects. If you inspect an instance, it feels like a...

If you require your Rails models manually, pay attention to the path you use. Unless you have...

If your application has forms to edit string fields, you probably want to strip the entered values (remove whitespace from...

blog.codeclimate.com

“Fat models” cause maintenance issues in large apps. Only incrementally better than cluttering controllers with domain logic, they usually represent...

Example task: Multiply the table holidays between several stages. Open two terminals: shell-for stage_1 shell-for stage_2...

If this happens to you: user.avatar = Avatar.new user.avatar # => nil (where avatar is a belongs_to), you probably declared your association...

Cucumber_rails' old-school web-steps have been deprecated for a while, urging developers to write high-level step definitions...

There is no reason to leave trailing whitespace characters in your project's files, so don't add any.

web.archive.org

TL;DR Avoid before(:context) (formerly before(:all)), use before(:example) (formerly before(:each)) instead. If you do use before...

makandra dev

Today I got a better understanding of how git works, in particular what git checkout and git reset do.

Given you store files on Amazon S3 and you need to stream those files out to people while you don...

StaticMatic is a nice tool to build simple static websites. In case you want to have some nifty styles on...

When you work in the MySQL console and you want to see which database is used, type: SELECT database();

We frequently use the handy Paperclip Gem to manage file attachments. If you need to move the files from local...

If you want to update some records with boolean fields in a migration, always remember to set your values with...

A print stylesheet is easy to create. Choose a font suited for paper, hide some elements, done. Unfortunately print stylesheets...

makandra dev

This article describes how to reset MySQL's or MariaDB's root password on your workstation. It's meant for...

Assuming the following sunspot setup of the post class: class Post < ActiveRecord::Base searchable do text :title string :state

Note: Instead of using the method in this card, you probably want to use ActiveType's nested attributes which is...

When committing, you should always check the diff of your changes so you don't include any leftovers or irrelevant/bad...

Sometimes you need to look at the filter chain in specs. You can do it like that on Rails 2...

So your Cucumber feature sometimes dies with this exception: Modal Dialog Present (Selenium::WebDriver::Error::UnhandledAlertError) As a seasoned Selenium...