How to disable “Cannot Render Console from…” on Rails

You need to specifically allow the 10.0.2.2 network space in the Web Console config. So you’ll want something like this: class Application < Rails::Application config.web_console.permissions=”10.0.2.2″ end Read here for more information. As pointed out by pguardiario, this wants to go into config/environments/development.rb rather than config/application.rb so it is only applied in your development environment.

Rails layouts per action?

You can use a method to set the layout. class MyController < ApplicationController layout :resolve_layout # … private def resolve_layout case action_name when “new”, “create” “some_layout” when “index” “other_layout” else “application” end end end

ActionController::InvalidAuthenticityToken

I had the same issue but with pages which were page cached. Pages got buffered with a stale authenticity token and all actions using the methods post/put/delete where recognized as forgery attempts. Error (422 Unprocessable Entity) was returned to the user. The solution for Rails 3: Add: skip_before_filter :verify_authenticity_token or as “sagivo” pointed out in … Read more

Best practices to handle routes for STI subclasses in rails

This is the simplest solution I was able to come up with with minimal side effect. class Person < Contact def self.model_name Contact.model_name end end Now url_for @person will map to contact_path as expected. How it works: URL helpers rely on YourModel.model_name to reflect upon the model and generate (amongst many things) singular/plural route keys. … Read more

How to solve error “Missing `secret_key_base` for ‘production’ environment” (Rails 4.1)

I had the same problem and solved it by creating an environment variable to be loaded every time I logged in to the production server, and made a mini-guide of the steps to configure it: I was using Rails 4.1 with Unicorn v4.8.2 and when I tried to deploy my application it didn’t start properly … Read more