In modern Rails versions you can also use ActiveRecord's pluck method. User.active.pluck(:id) => [1, 5, 23, 42]

You should test the callback methods and its correct invocation in two separate tests. Understand the ActiveRecord note before you...

github.com

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

When you load a record with find options that have SQL fragments in :select or :joins, ActiveRecord will make that...

yehudakatz.com

This post explains, in some detail, how we will implement a nice performance boost for Rails developers. Understanding the details...

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

github.com

jamesgolick / resource_controller at Github module ResourceController module Actions def index load_collection before :index response_for :index end

When doing a query like this: SELECT id FROM users WHERE (users.id IN (899,1084,1095,100,2424,2429,2420...

github.com

An alternative to this technique is using VCR. VCR allows you to record and replay real HTTP responses, saving you...

Open the configuration file: gksudo gedit /usr/share/vte/termcap/xterm Find a line like this: :co#80:it#8:li#24:\

In a nutshell: to avoid your shell character set from messing with imports, use -r to export and SOURCE when...

ALTER DATABASE database_name CHARACTER SET "utf8"; ALTER DATABASE database_name COLLATE "utf8_unicode_ci"; After that, for...

github.com

home_run is an implementation of ruby’s Date/DateTime classes in C, with much better performance (20-200x) than...

github.com

Ancestry is a gem/plugin that allows the records of a Ruby on Rails ActiveRecord model to be organised as a...

makandra dev

This may be awkward to set up, but will work once you're done. Fun facts:

Unless all MySQL server defaults are set to UTF-8, mysqldump encodes UTF-8 characters incorrectly and only outputs correct...

makandra dev

To test concurrent code, you will need to run multiple threads. Unfortunately, when you use blocking system calls (e.g. locks...

makandra dev

Install gem and plugin sudo gem install parallel script/plugin install git://github.com/grosser/parallel_tests.git Adapt config/database.yml test: database: xxx_test<%= ENV...

makandra dev

This is about converting Haml to ERB and not the other way round which you probably want! This process can...

sudo gem install zip git clone git://github.com/rtomayko/date-performance.git cd date-performance rake package:build cd dist sudo gem install...

ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "#{Location.solr_configuration[:type_field]}:#{ModelClass}")) ActsAsSolr::Post.execute(Solr::Request::Commit.new)

This can happen during development when classes without automatic reloading are pointing to classes with automatic reloading. E.g. some class...

makandra dev

tmp/* storage/* db/*.sqlite3 db/schema.rb db/structure.sql public/system .project .idea/ public/javascripts/all* public/stylesheets/all* public/stylesheets/*.css config/database.yml *~ *#* .#* .DS_Store webrat-*.html