Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ttdonovan/308563 to your computer and use it in GitHub Desktop.
Save ttdonovan/308563 to your computer and use it in GitHub Desktop.
# Setup for Heroku, Rails 2.3.5, Bundler 0.9.7, Clearance 0.8.6 (and Plugins)
$ gem uninstall bundler
$ gem install bundler --version '=0.9.7'
$ gem install heroku
$ rails heroku_gems_and_plugins_01
$ cd heroku_gems_and_plugins_01
$ bundle init
$ mate Gemfile
source :gemcutter
source 'http://gems.github.com'
source :gemcutter
gem 'rubygems-update'
gem 'rails', '2.3.5', :require => nil
gem 'clearance', '0.8.6'
group :development do
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
end
group :production do
gem 'pg'
end
$ bundle install
$ bundle show
Gems included by the bundle:
* actionmailer (2.3.5)
* actionpack (2.3.5)
* activerecord (2.3.5)
* activeresource (2.3.5)
* activesupport (2.3.5)
* clearance (0.8.6)
* pg (0.8.0)
* rack (1.0.1)
* rails (2.3.5)
* rake (0.8.7)
* rubygems-update (1.3.5)
* sqlite3-ruby (1.2.5)
$ script/generate clearance
$ mate config/boot.rb
# Add this to the bottom of config/boot.rb, before the line `Rails.boot!` http://gist.github.com/302406
class Rails::Boot
def run
load_initializer
extend_environment
Rails::Initializer.run(:set_load_path)
end
def extend_environment
Rails::Initializer.class_eval do
old_load = instance_method(:load_environment)
define_method(:load_environment) do
Bundler.require :default, RAILS_ENV
old_load.bind(self).call
end
end
end
end
Rails.boot!
$ mate config/preinitializer.rb
# http://gist.github.com/306996
begin
# Require the preresolved locked set of gems.
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
# Fallback on doing the resolve at runtime.
require "rubygems"
require "bundler"
Bundler.setup
end
$ git init
$ git add .
$ git commit -m "init rails 2.3.5 bundler 0.9.7 clearance 0.8.6"
$ heroku create herokugemsandplugins01
$ git push heroku master
$ git heroku consol
>> OK exit
$ script/generate controller sessions
$ mate app/controllers/sessions_controller.rb
class SessionsController < Clearance::SessionsController
def self.foobar
return "baz"
end
end
$ git add .
$ git commit -m "Adding Sessions Controller inherit from Clearance Plugin"
$ git push heroku master
$ heroku console
[warning] The response contained in an RestClient::Exception is now a RestClient::Response instead of a Net::HTTPResponse, please update your code
Couldn't run console command
App failed to start:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:426:in `load_missing_constant': Expected /disk1/home/slugs/134994_28471d9_514d/mnt/app/controllers/sessions_controller.rb to define SessionsController (LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:437:in `load_missing_constant'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
from /disk1/home/slugs/134994_28471d9_514d/mnt/app/controllers/sessions_controller.rb:1
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:265:in `require_or_load'
... 26 levels...
from /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in `instance_eval'
from /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in `initialize'
from /home/heroku_rack/heroku.ru:1:in `new'
from /home/heroku_rack/heroku.ru:1
$ mate config/boot.rb
Rails.boot!
# Make sure Rails.boot! is above these block! http://gist.github.com/306996
class Rails::Plugin::GemLocator
def plugins
dirs = []
Bundler::SPECS.each do |spec|
spec[:load_paths].each do |path|
if File.exist?(File.join(path, "..", "rails", "init.rb")) || File.exist?(File.join(path, "..", "init.rb"))
dirs << File.expand_path(File.join(path, ".."))
end
end
end
dirs.uniq.collect do |dir|
Rails::Plugin.new(dir) # TODO ordering
end
end
end
$ git add .
$ git commit -m "Adding Rails::Plugin::GemLocator hack http://gist.github.com/306996"
$ git push heroku master
$ heroku console
>> SessionsController.foobar
=> "baz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment