Quantcast
Channel: rails – Paweł Gościcki
Browsing all 20 articles
Browse latest View live

Rails helpers. Rediscovered

Normally, you’d use partials to manage some common functionality in a single file. For example like this: Somewhere in your view: <%= render :partial => 'ads/ad', :locals => {:placement =>...

View Article


Rails and Merb together

Or putting it in another words: Merb will be merged into Rails to become Rails 3.0. Is it 1st April just way too soon or what? – was my first thought the moment I’ve read it on the Ezra’s blog. But...

View Article


Mocha. The stubbing library

This example (shortened here): class Order def shipping_cost total_weight * 5 + 10 end end require 'test/unit' require 'rubygems' require 'mocha' class OrderTest < Test::Unit::TestCase # illustrates...

View Article

On Heroku

While Heroku is nice and all, it suffers from the same disease as every other hosted-for-you solution: $ git push heroku (...) -----> Gemfile detected, running Bundler version 1.0.7 (...) $ bundle...

View Article

hookup is the shit!

This is simply amazing: $ g pull Already up-to-date. $ g co edge Switched to branch 'edge' == AddFileTypeToSong: migrating ============================================== -- add_column(:songs,...

View Article


Run guard-jasmine-headless-webkit without X server

You write specs for your javascript, right? If not, you really should. jasmine-headless-webkit really helps with that. guard-jasmine-headless-webkit makes it all even more enjoyable, although there’s...

View Article

Bug of the day

Completely bad code follows, beware. Silent error in Ruby 1.8.7: x = [:a, :b] => [:a, :b] x.slice!(:a) => nil x => [:a, :b] Explicit error (resulting in a failing test) in Ruby 1.9.2: x = [:a,...

View Article

Tell bundler to install gems globally when using capistrano

Seems like it’s not so straightforward. Here’s the excerpt from my config/deploy.rb: require "bundler/capistrano" set :bundle_dir, "" # install into "system" gems set :bundle_flags, "--quiet" # no...

View Article


Uninitialized constant Gem::Deprecate

If you run into this problem, which by the way usually happens after upgrading the rubygems package (in my case it was to version 1.8.21), your best bet is to upgrade the gem from the backtrace of this...

View Article


Testing CSRF protection in Rails

Ever wanted to test your CSRF protection in a Rails app? For example, in a situation when you have a custom “remember me” cookie set and you need to overwrite Rails’ handle_unverified_request to clear...

View Article

On Heroku

While Heroku is nice and all, it suffers from the same disease as every other hosted-for-you solution: $ git push heroku (...) -----> Gemfile detected, running Bundler version 1.0.7 (...) $ bundle...

View Article

hookup is the shit!

This is simply amazing: $ g pull Already up-to-date. $ g co edge Switched to branch 'edge' == AddFileTypeToSong: migrating ============================================== -- add_column(:songs,...

View Article

Run guard-jasmine-headless-webkit without X server

You write specs for your javascript, right? If not, you really should. jasmine-headless-webkit really helps with that. guard-jasmine-headless-webkit makes it all even more enjoyable, although there’s...

View Article


Bug of the day

Completely bad code follows, beware. Silent error in Ruby 1.8.7: x = [:a, :b] => [:a, :b] x.slice!(:a) => nil x => [:a, :b] Explicit error (resulting in a failing test) in Ruby 1.9.2: x = [:a,...

View Article

Tell bundler to install gems globally when using capistrano

Seems like it’s not so straightforward. Here’s the excerpt from my config/deploy.rb: require "bundler/capistrano" set :bundle_dir, "" # install into "system" gems set :bundle_flags, "--quiet" # no...

View Article


Uninitialized constant Gem::Deprecate

If you run into this problem, which by the way usually happens after upgrading the rubygems package (in my case it was to version 1.8.21), your best bet is to upgrade the gem from the backtrace of this...

View Article

Testing CSRF protection in Rails

Ever wanted to test your CSRF protection in a Rails app? For example, in a situation when you have a custom “remember me” cookie set and you need to overwrite Rails’ handle_unverified_request to clear...

View Article


Enabling I18n locale fallbacks in Rails

This guide is valid for i18n version 0.7.0+ and Rails 4.1+ Strangely enough enabling custom locale fallbacks is harder than it should be. Here’s what you need to enable custom locale fallbacks with...

View Article

Testing database transactions explicitly with RSpec

TL;DR; you cannot do it reliably with RSpec. The long story goes like this. Lets say you have a code executing an AR rollback when something fails: def call Model.transaction do update_reason unless...

View Article

Run Rails 2.3 application using Ruby 2.1

There is a way to have your old Rails 2.3.something application running using latest Ruby from the 2.1 branch. However, it is moderately complex and requires quite a few hacks. Not everything works...

View Article
Browsing all 20 articles
Browse latest View live


Latest Images