Yesterday, Rails fixed a security issue (CVE-2014-3514) in Rails 4+. It was possible to use .where or .create_with to bypass Rails' Strong Parameters: user.blog_posts.create_with...

...know .create_with existed, have a look at the API. How this applies to Rails 3 In Rails 3, Strong Parameters did not exist, yet. Instead, you used mass assignment...

makandra dev

...and The...

...field should have the error...

...steps now have built-in support for Rails and Bootstrap (v3-v5) error classes. When using Bootstrap, it is no longer necessary to...

Add deprecation warnings and their solution or link to available solutions. Global access to Rake DSL methods is deprecated. Please...

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...

When working with times and dates in Rails applications, you need to deal with the following problem: In Rails, Time objects have a time zone. You can get the zone...

...just stores the literal string "2010-05-01 12:00:00". That means that Rails must make assumptions about timestamps loaded from and written to MySQL. Rails has two completely...

ariejan.net

Rails understands a :limit options when you create columns in a migration. Its meaning depends on the column type, and sometimes the supplied value. The documentation states that :limit sets...

...token authenticity" even if csrf token is present? As :domain => :all is set in Rails 3, local session cookies seem not to be set unless you specify a top-level...

Solutions Use a dns wildcard service like lvh.me and set :domain => 'lvh.me' if Rails.env.development? Then you can access your local server with lvh.me:3000 or anysubdomain.lvh.me:3000. Another way is, to...

Rails flashes (FlashHash) track a list of used keys, which is not respected when comparing flash hashes. This does not concern you under most circumstances. Basics When ActionController picks up...

...method which checks for that: ActionController::Flash::FlashHash.class_eval do # This is from a Rails 2 project. For Rails 3, say: # ActionDispatch::Flash::FlashHash.class_eval do def same?(other_flash...

...setting the :x_sendfile option to true. This option is activated by default for Rails 3, so you need to understand this. What this option does is not to send...

...as a new response header: X-Sendfile: /opt/www/awesome-project/shared/downloads/image.png When the response comes back from Rails to Apache for delivery, Apache will detect that header and replace the empty response body...

...has to wait until the thread of one of the workers is free. Threads Rails is thread-safe since version 4 (note that not all gems are thread-safe). This...

...for the related config/puma.rb: workers Integer(ENV['WEB_CONCURRENCY'] || 2) threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) Note: Having multiple workers in development and tests might cause unexpected issues...

If a model inherits from others or uses many concerns / traits, it might be hard to see in the code...

You have to specify the environment with -e env_name or RAILS_ENV=env_name if you want to run a script on the server. at Rails 2 it's...

bundle exec script/runner -e env_name path/to/script.rb argument1 argument2 ... at Rails 3 it's rails runner RAILS_ENV=env_name bundle exec rails runner path/to/script.rb argument1 argument2...

...locale/de/app.po for every locale you want to use use method "_" like _('text') in your rails code run rake gettext:find to let GetText find all translations used translate messages in...

...locales = [ 'en', 'de' ] FastGettext.add_text_domain('app', :path=>'locale', :type=>:po) FastGettext.text_domain = 'app' Rails::Initializer.run do |config| # Versionsnummern selber rausfinden: config.gem 'spreadsheet', :version => '=0.6.4.1' config.gem "fast_gettext", :version...

...all styling inline, which means you'll have to do your styling inline. For Rails applications, you can use Roadie or premailer, which lets you keep your well-structured CSS...

...passive maintenance mode, we go with premailer: Include premailer in your Gemfile: gem 'premailer-rails' In your ApplicationMailer define the mailer layout: layout 'mailer' To get the mailer stylesheet (and...

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...

Plugins (and gems) are typically tested using a complete sample rails application that lives in the spec folder of the plugin. If your gem is supposed to work with multiple...

...versions of Rails, you might want to use to separate apps - one for each rails version. For best practice examples that give you full coverage with minimal repitition of code...

There is a nasty bug in all version of Rails 2 and some versions of Rails 3.x where two chained scopes with hash conditions on the same attribute would...

...what a user may see or change. Workaround If you are using an affected Rails version and cannot switch to a fixed version, you can use this manual workaround.

github.com

...Gruff for easily plotting graphs. It is written in pure Ruby and integrates with Rails applications. It provides features as automatic sizing of dots and lines (the more values, the...

...restart your development server.) Usage This is a common example for graph generation in Rails. Note that you have many configuration options at hand that are not documented. Github and...

In Rails 5 you can say: ApplicationController.render( :template => 'users/index', :layout => 'my_layout', :assigns => { users: @users } ) If a Request Environment is needed you can set attributes default attributes or initialize a...

...host: 'example.org', https: false ) renderer.render( :template => 'users/index', :layout => 'my_layout', :assigns => { users: @users } ) In Rails 3 and 4 you can say: ApplicationController.new.render_to_string( :template => 'users/index', :layout => 'my_layout',

api.rubyonrails.org

Rails 5 (don't know about the others) comes with an initializer wrap_parameters.rb. Here you can tell rails to wrap parameters send to your controllers for specific formats into a...

...used to when you are dealing with form payloads. This is especially handy because Rails puts some stuff in the params which does not really belong there IMHO. For instance...

...in development. This is usually useful, but when you run into issues with the Rails autoloader, you should take a look at what it's doing. For me this was...

...of auto-loading classes inside a thread which caused the application to stop responding. Rails 4.x ActiveSupport::Dependencies includes logging support. It is easy to use: ActiveSupport::Dependencies.logger = Rails.logger...

...writing a piece of reusable code, you sometimes need to have separate code for Rails 2 and Rails 3. You can distinguish between Rails versions like this: if Rails.version...

...mind the quotes # Rails 2 code goes here else # Rails 3+ code goes here

rails-assets.org

...Rubygems) it will provide the Jasmine library to your asset pipeline. When you then install rails-assets-jasmine-fixture through Rails Assets you will get another (possibly conflicting) copy of...

...Jasmine installed through Rails Assets. This is because rails-assets-jasmine-fixture depends on rails-assets-jasmine and does not realize that the Jasmine dependency was already satisfied through jasmine...

You will need to upgrade to RSpec >= 2 and rspec-rails >= 2 for Rails 3. Here are some hints to get started: In RSpec 2 the executable is rspec, not...

RSpec and rspec-rails have been completely refactored internally. All RSpec classes have been renamed from Spec::Something to RSpec::Something. This also means that every require 'spec/something' must...