...but install the version from the webpage instead. Get Bundler: sudo gem install bundler Rails and other gems for a project should now be installed via bundle install from the...
...project directory. If you need Rails and don't have a Gemfile you can do it old-school: sudo gem install rails -v=2.3.12. You will also need Ubuntu development...
ActiveRecord has a feature called counter caching where the containing record in a has_many relationship caches the number of its children. E.g. when you have House has...
...many :rooms, Rails can cache the number of rooms in House#rooms_count. Mind that when a model has a column that looks to Rails like a counter-cache column...
The most obvious way to use spring is to call it explicitly: spring rails console spring rake db:migrate Binstubs Binstubs are wrapper scripts around executables. In Rails they...
...all, your binstubs will be using Spring. bin/rails console bin/rake db:migrate bundle exec rails ... Bundle exec is inconsistent when it comes to spring. Some commands will use it, some...
...got this error after upgrading Ruby from 2.4.5 to 2.6.4 when I opened the Rails console - rails server still worked. Running via Spring preloader in process 14679 Loading development environment...
Traceback (most recent call last): .../lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:175:in 'fork': No such file to load -- irb/encoding_aliases.rb (LoadError) .../lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:175:in 'fork': undefined method 'reject!' for nil:NilClass (NoMethodError) .../lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb...
Starting with Rails 4.0, when you get an exception reported via the ExceptionNotification gem, you will only see a very short backtrace with all backtrace lines from gems or ruby...
...libraries missing. This happens, because the ExceptionNotification gem uses Rails' default backtrace cleaner. To get a full backtrace in exception emails, you can remove the comment from this line in...
In Rails 3.1+, instead of defining a separate up and down method you can define a single method change: class AddComparisonFieldsToReport < ActiveRecord::Migration def change add_column :reports, :compare, :boolean...
...additional step to keep your cookies valid. Issue Sidekiq::Web is mounted into your Rails application and will use the Rails session cookie for protection from CSRF attacs. While it...
...Sidekiq::Web like this: # config/initializers/sidekiq.rb require 'sidekiq/web' Sidekiq::Web.set :sessions, domain: <domain here, e.g. Rails.configuration.x.cookie_domain...
...list like this: ----- Passenger processes ----- PID VMSize Private Name ------------------------------- 671 112.9 MB 95.5 MB Rails: /opt/www/project1/current 707 79.4 MB 60.5 MB Rails: /opt/www/project2/current 1094 88.1 MB 69.3 MB Rails: /opt/www/project3/current...
...MB 62.6 MB Rails: /opt/www/project4/current 1269 72.9 MB 55.6 MB Rails: /opt/www/project5/current
...go, all you need to do is prefix every command with zeus. That means rails server becomes zeus server, rails console becomes zeus console, and so on. From the Github...
Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second. Requirements: OS X 10.7+ or Linux...
...it will look like this: >> Socket.gethostname => "happycat" That should work right away for your Rails application. For plain Ruby, you first need to do: require 'socket'
...often is) different from the host that a user is requesting in their current Rails session (request.host). Also keep in mind that hostname might give you the FQDN depending on...
Add deprecation warnings and their solution or link to available solutions. Global access to Rake DSL methods is deprecated. Please...
...require to require_relative where I loaded RSpec factories in Cucumber's env.rb (the Rails application root is no longer in the load path by default) replacing the old debugger...
...to your Gemfile. iconv is a part of Ruby that was removed in 2.0. Rails 3 seems to depend on it. All the pain with magic # encoding: utf-8 comments...
You don't need a Rails application to use Sass. Even when you're working on a static site you can generate your CSS through Sass. Install Sass with sudo...
...gitignore to not exclude public/stylesheets/*.css, since stylesheets aren't being generated automatically without Rails (this would bite you after a deploy). Instead exclude .sass-cache, which will be created...
Run bundle update cucumber capybara cucumber-rails to update to the newest versions. Backup your features/support/path.rb to be able to add your own paths again after the cucumber installation script...
...your features/support/env.rb file to be able to reintegrate parts like your blueprints setup: ENV["RAILS_ENV"] ||= "cucumber" require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') require 'spec/support/blueprints' Run $ rails generate cucumber:install...
...images, this slows down development response times. You can fix that by defining a Rails route like this: if Rails.env.development? scope format: true, constraints: { format: /jpg|png|gif/ } do
...root path: xsendfile: unable to find file: /tmp/foo20110721-28050-1h104da-0 The reason for this is that Rails 3 uses X-Sendfile for file downloads and Apache is only allowed to transfer files...
Last week saw a security issue with rails 2.3 that required a fix. While an official patch was provided, the 2.3 branch is no longer maintained. So we forked it...
...but they are not very easily discoverable.) To use our fork, change the gem "rails"... line in your Gemfile to this: gem 'rails', :git => 'https://github.com/makandra/rails.git', :branch...
Ever wondered how Rails talks to itself in a Cucumber feature? In Rails 3 you can do it like this: def rack_env(path) { "rack.input" => {}, "PATH_INFO"=>"#{path}", "REQUEST_METHOD...
end request = rack_env('/users/new') response = Rails.application.call(request) status, headers, body = response puts status # e.g. 200 puts headers.inspect # hash of headers puts body.body # html of response body
Under certain (unknown) circumstances, Rails will give localized files an invalid content-type in the Response header. For me, after requesting corporate_information and rendering corporate_information.de.html.haml, Rails sent a content...
...topic that offer workarounds, but none solved it for me. The issue occurred with Rails...
You either have an old version of Mocha and an edge version of Rails 3.2, or you have a new version of Mocha and an old version of Rails. The...
...best solution is to update Mocha to the latest version and switch to Rails edge. If you are using shoulda-matchers or another gem that locks Mocha to an old...
...installing Bundler 1.1 you will get the following warning when running tests: WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called...
...To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile The warning is misleading because it has nothing to do with moving cucumber-rails into...
...is a MongoDB adapter for Ruby. We've forked it so it works for Rails 2.3.x applications running on Ruby 1.9. [1] makandra/mongomapper is based on the "official" rails2...
...it, add this to your Gemfile: gem 'mongo_mapper', :git => 'git://github.com/makandra/mongomapper.git', :branch => 'rails2' [1] The last version to be compatible with Rails 2 was 0.8.6: While there are...
Rails 4.0 is finally ready after a thorough process of betas and release candidates. It's an amazing new version packed with new goodies and farewells to old features past...
Gem to generate entity relationship diagrams from your Rails 3 ActiveRecord models. The diagram style is pretty and configurable...