Skip to content

Instantly share code, notes, and snippets.

View fnhipster's full-sized avatar
💭
clear cache && refresh

Carlos A. Cabrera fnhipster

💭
clear cache && refresh
View GitHub Profile
@fnhipster
fnhipster / gist:756325
Created December 27, 2010 17:33
Route 404 in Rails 3
# routes.rb
...
constraints(:subdomain => "sub_domain_name") do
match "*id" => "pages#four_o_four"
end
...
# pages_controller.rb
...
def four_o_four
@fnhipster
fnhipster / gist:747856
Created December 20, 2010 00:08
Get next record while it exists.
def some_method
self.find(:all, :order => "position DESC").each do |obj|
next_obj = self.find(:first, :conditions => ["position > ?", obj.position], :order => "position DESC")
# ...
break if next_obj == self.last
end
end
@fnhipster
fnhipster / Setting_Up_Cucumber_Rails3.rb
Created August 23, 2010 21:29
Setting up Cucumber on Rails 3
# /Gemfile
# We do Behaviour Driven Development
group :development, :test do
gem 'cucumber'
gem 'cucumber-rails'
gem 'webrat'
end
#---
@fnhipster
fnhipster / env.rb
Created August 13, 2010 19:59 — forked from mborromeo/env.rb
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support