Odd referrer issue

Posted Over 10 years ago by dncrht.

The request referrer is the URL you come from. It's set by the browser when you click a link...

Bundle install in parallel

Posted Over 10 years ago by Tadej.
github.com

Gave a shot to the new Bundler 1.4.0RC1 during the weekend and found out it now supports gem installation...

jQuery ajax success/done will not run callbacks if request is json but the response is empty (typical 200)

Posted Almost 11 years ago by [Removed].

var onDone = function() {...

var onFail = function() {...

var params = {...

var url = ... $.ajax({ type: 'put', url: url, contentType: 'application/json; charset...

Error: unable to read font `/usr/local/share/ghostscript/fonts/n019003l.pfb' @ error/annotate.c/RenderFreetype/1123: `(null)'

Posted Almost 11 years ago by [Removed].

This happens when your machine does not have ghostscript installed, to fix it simply do brew install ghostscript

If you GROUP BY, make sure you ORDER BY NULL

Posted Almost 11 years ago by Marcus Mitchell.

TL;DR: If using :group => :some_field you might want to :order => 'NULL'. According to the man By default, MySQL...

DateTimes are Dates, beware

Posted About 11 years ago by dncrht.

datetime = DateTime.now date = datetime.to_date #or Date.today will assert: datetime.is_a? Date == true datetime.is_a? DateTime == true datetime.instance_of...

When you set date attributes, you should not pass times

Posted About 11 years ago by Arne Hartherz.

As you know, time zones make stuff a bit more difficult but are necessary. A time-zoned record is converted...

Find out branches containing a commit

Posted About 11 years ago by Dragos Miron.

If you have a commit and you want to see in what branches is is included, you have to write...

Profiling Ruby with ruby-prof

Posted About 11 years ago by Nasir Jamal.

require 'ruby-prof' # you don't need this if you have ruby-prof in your Gemfile You can set one...

has_defaults issues

Posted Over 11 years ago by Dragos Miron.

The object returned by has_defaults apparently is the same between multiple object creations. Consider this scenario:

Killing wkhtmltopdf during cucumber

Posted Over 11 years ago by Nasir Jamal.

wkhtmltopdf hangs on mac during cucumber unless we click on it. The main reason is with the version we use...

To avoid using bundle exec or creating rvm gemsets

Posted Over 11 years ago by Nasir Jamal.

Add to the end your .bash_profile export PATH="./vendor/bundle/bin:$PATH" Also add alias bi="bundle install --path vendor/bundle --binstubs...

How to run long scripts on production/staging server

Posted Over 11 years ago by Dragos Miron.

In a nutshell, use screen Why? Sometimes we are concerned that if our connection gets closed, the process we are...

Database: Scopes, migrations, and indices

Posted Over 11 years ago by Julien Letessier.

Wether you modify an existing named scope or add a new one, or when you write a new query, make...

Cleaner Rspec

Posted Over 11 years ago by Nasir Jamal.

When simply checking equality or truthiness then Instead of: it "should have role set to admin" do @user.role.should eql('admin...

Method return value should always be of same type

Posted Over 11 years ago by Nasir Jamal.

One of the main source of bugs and complexity in the code is when a functional method (that we expect...

Add indexes on foreign keys when you create a migration (with foreign key)

Posted Over 11 years ago by Dragos Miron.
tomafro.net

Whenever you make a migration to add a foreign key, you should also add an index for it

Writing raw SQL queries

Posted Over 11 years ago by Julien Letessier.

If you really, really have a good reason to write raw SQL (generally a bad practice), make sure you use...

Caching: don't use content_for, it won't work

Posted Over 11 years ago by Dragos Miron.

Do not use content_for inside a cached view fragment. It won't work because Memcache will just output whatever...

Creating a gem in lib folder

Posted Over 11 years ago by fragalla.
github.com

Go to lib folder and use bundler to generate main files for a gem: $ bundle gem test_gem create test...

Rebase your feature branches

Posted Over 11 years ago by Arne Hartherz.

Regularly, but at least before merging your feature branches, rebase them to get rid of "fix typo" and "wip" commits...

Respect time zones: Use Time.current and Time.zone.parse

Posted Over 11 years ago by Arne Hartherz.
makandracards.com

Reading the current time Don't use Time.now as it's broken when using time zones. \ Instead, use Time.current, DateTime.current...

ActiveRecord::NamedScopes (2.3.x) obtaining the SQL conditions

Posted Over 11 years ago by [Removed].

It's a good pratice to chain several named scopes like: Property.listable.for_2_or_more_guests.best_10_properties Now, to make the lesson more...

Keeping your specs DRY

Posted Almost 12 years ago by Julien Letessier.

I often see long before blocks with lots of should_receive...

...and_return inside. Remember that before blocks are about...