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

Extending controllers of a Rails 3 Engine in the main app

By design, classes in a Rails::Engine are supposed to be scoped to the engine. That way they don’t introduce strange bugs by accidentally stomping all over code loaded in the main app or by other engines. Monkeypatching ActiveSupport::Dependencies to mix engines across-the-board is a really bad workaround. Just use a Rails::Railtie, instead. They have all … Read more

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

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

How to use bundler behind a proxy?

OSX & Linux export http_proxy=http://user:password@host:port export HTTP_PROXY=$http_proxy If it’s using HTTPS, set it as well export https_proxy=http://user:password@host:port export HTTPS_PROXY=$https_proxy If you use sudo, by default sudo does not preserves http proxy variable. Use -E flag to preserve it $ sudo -E bundle install to make sudo preserves environment variables by default: Bash http_proxy: from a … 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

tech