Where there was once a consistent API to manipulate and hook into the lifecycle of a persistent object, plugins must...
This will only work with warnings that go through ActiveSupport and only in Rails 3.0 or higher...
Starting from 4.1, Rails automatically detects the inverse of an association, based on heuristics. Unfortunately, it does not seem to notify you when it fails to infer the :inverse_of...
Rails' params hash contains any request parameters (URL parameters or request payload) as well as routing parameters like :controller, :action, or :id. To access only URL parameters, use request.query_parameters...
Rails 5 will introduce ActiveRecord::Relation#or. On Rails 4 and 3.2 you can use the activerecord_any_of gem which seems to be free of ugly hacks and nicely...
After starting the Rails server in a freshly generated Rails 3.1 project you could see an error message such as /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect': Could not find a JavaScript runtime...
Don't write resources :people, :concerns => :trashable Write resources :people do concerns :trashable end Why Writing a controller...
In specs, the session never persists but is always a new object for each request. Data put into the session...
When using form_for you can give the form's target URL either as a string or an array:
You might find that your Passenger ignores all RailsSomething directives in the vhost for your new Rails 3 application. The culprit is a file config.ru which makes Passenger consider your...
...application a Rack (non-Rails) application. To fix this you can either use RackEnv in lieu of RailsEnv (it works fine) or delete the config.ru. Unless you have a good...
Rails 2.3.16+ on Ruby 1.9 causes warnings like this: .../gems/activesupport-2.3.17/lib/active_support/core_ext/string/output_safety.rb:22: warning: regexp match /.../n against to UTF-8 string Many thanks to grosser for supplying a monkey-patch for...
...Rails 2.3 (Commit f93e3f0ec3 fixed it for Rails 3). Just put it into config/initializers/ to make those warnings go away. Since we're using RSpec on most projects, I've...
Today I learned that Ruby on Rails has shipped with a built-in slug generator since Rails 2.2: > "What Up Dog".parameterize => "what-up-dog" > "foo/bar".parameterize => "foo-bar"
Rails’ reputation as a relatively secure Web framework is well deserved. Out-of-the-box, there is protection against many common attacks: cross site scripting (XSS), cross site request forgery...
...the default behavior could be more secure. This post explores potential security issues in Rails 3 that are fixed in Rails 4, as well as some that are still risky...
The Ruby on Rails security list archive can be found here: http://groups.google.com/group/rubyonrails-security You can subscribe to this mailing list without a Google account by pasting this URL into...
Rails 4 introduced raising an error on pending migrations. This is most annoying when you are crafting a migration but need to play with your application to figure out how...
After switching to Rails 3 you may get a LoadError with the following message when trying to use your application via passenger: no such file to load -- dispatcher Your Passenger...
...RVM on a Mac and cannot enter 8+ bit characters on an IRB or Rails console, you are missing the readline package. You will need to re-install your Ruby...
January has been a very bad month for Ruby on Rails developers, with two high-severity security bugs permitting remote code execution found in the framework and a separate-but...
...related compromise on rubygems.org, a community resource which virtually all Ruby on Rails developers sit downstream of. Many startups use Ruby on Rails. Other startups don’t but, like the...
...root_url, :data => { :foo => 'bar', :bam => 'baz' } This will produce: Label Only works in Rails 3. In Rails 2 you do = link_to 'Label', root_url, 'data-foo' => 'bar', 'data...
We're adding a script console-for to open a remote Rails console with one command. Also have a look at shell-for, which this script is relying on.
This card needs to be updated for Rails 3+. Since there is no --debugger flag you need to run: rdebug script/runner lib/scripts/something.rb That will open an debugging IRB right away...
Let's say you need to revert a migration that happened a while back. You'd create a new migration...
Yesterday, there was a blog post entitled “What the Hell is Happening to Rails” that stayed at the number one spot on Hacker News for quite a while. The post...
...the comments on the post reflect deep-seated concern about the recent direction of Rails. Others have addressed the core question about change in the framework, but I’d like...
...a dump from db/production_structure.sql: class LoadDump < ActiveRecord::Migration def up config = YAML.load_file('config/database.yml')[RAILS_ENV].symbolize_keys config[:flags] = Mysql2::Client::MULTI_STATEMENTS client = Mysql2::Client.new(config) sql = File.read...