Rails Engine – Gems dependencies, how to load them into the application?

Include them in your gemfile and run bundle install. Then require them in your lib/<your_engine>/engine.rb file. Don’t forget to require rubygems require ‘rubygems’ require ‘paperclip’ require ‘jquery-rails’ require ‘rails3-jquery-autocomplete’ require ‘remotipart’ require ‘cancan’ Then in your host app (The app where you included your gem) run bundle install/ bundle update (bundle update did the trick … Read more

Overriding a module method from a gem in Rails

A more concise solution: WillPaginate::Finder::ClassMethods.module_eval do def paginate_by_sql sql, options # Your code here end end Put the the code into an initializer file in config/initializers. This is the correct place to put code that needs to be run when the environment is loaded. It also better organises your code, making each file’s intent clearer, … Read more

gem install permission problem

Try setting GEM_HOME and GEM_PATH to ~/.gem, For the current terminal session, just type: export GEM_HOME=~/.gem export GEM_PATH=~/.gem If you want these to be set whenever you open a terminal, add the above commands to your ~/.bashrc file. For a more comprehensive solution to setting up a custom ruby environment, see this tutorial from Site5KB, … Read more

Installing Nokogiri on OSX 10.10 Yosemite

I managed to install Nokogiri under Yosemite (OS X 10.10 Preview). Step 1: Install Brew Skip this if brew was installed. ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” Step 2: Install brew libs brew tap homebrew/dupes brew install libxml2 libxslt brew install libiconv Step 3: Download and install Apple Commandline Tools for 10.10 It’s important that you … Read more

Cannot install JSON gem in rails using windows

You are working with Windows, so the RubyInstaller Development Kit may help you: http://rubyinstaller.org/add-ons/devkit/ The devkit installs a C-compiler (and some other stuff) to compile C-written parts. Install it and try again to install the gem – perhaps with option –platform=ruby. Details can be found at https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

“gem install therubyracer -v ‘0.10.2’” on osx mavericks not installing

If you decide to use a newer therubyracer gem version, you will no longer have this problem Otherwise: brew tap homebrew/dupes # Thanks Tom brew install apple-gcc42 export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2 brew uninstall v8 gem uninstall libv8 gem install therubyracer -v ‘0.10.2’ # specify version

Heroku deployment failed because of sqlite3 gem error

Heroku can’t install the sqlite3 gem, for whatever reason. But you can tell bundler that it shouldn’t be trying to except when developing. In your Gemfile, replace gem ‘sqlite3’ with: group :development, :test do gem ‘sqlite3’ end group :production do gem ‘pg’ end Then bundler on heroku, running as production, won’t try to install it.