Please don't use the horrible datetime_select helper. It has a terrible UI. Always prefer to use a visual...

markembling.info

Using uncountable resources is not recommended as it breaks Rails' magic, e.g. when using form_for. You'll always be better off using simple pluralizable resources. Rails automatically creates path...

...will refer to the show action: /sheep/:id. Solution As the linked article states, Rails creates a special _index_path for this scenario. Thus, you can simply call:

In FactoryBot factories, Rails' file_fixture is not available by default. To enable it, include a support module from rspec-rails: FactoryBot::SyntaxRunner.include(RSpec::Rails::FileFixtureSupport) That includes ActiveSupport::Testing...

dusen 0.4.8 and edge_rider 0.2.3 no longer depend on Rails (they still depend on ActiveRecord). That means you can use them e.g. with Sinatra...

There are a few ways to access view helpers from the Rails console. The easiest way is the helper shortcut: helper.translate 'i18n.string' helper.your_helper_method If the desired helper renders...

...a view template, you need this setup: view_paths = Rails::Application::Configuration.new(Rails.root).paths["app/views"] av_helper = ActionView::Base.new(view_paths).extend YourHelperModule av_helper.your_helper_method

...revert to the original Rubygems by saying gem uninstall slimgems #If you are using Rails 2.3.11 Rails 2.3.11 can also trigger this warning. Install 2.3.12+. After installation, you need to...

guides.rubyonrails.org

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

github.com

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

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

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

...our older projects, we use the mysql2 gem. Unfortunately, versions 0.2.x (required for Rails 2.3) and versions 0.3.x (required for Rails 3.2) can no longer be installed on...

...to errors when compiling the native extension, or a segfaults when using it. For Rails 4.2, mysql2 version 0.4.10 seems to work okay. If you still have issues, upgrade to...

User.active.to_sql Rails 2 Use either the Edge Rider or fake_arel gem to get #to_sql backported to Rails 2. If you don't want to use...

...a gem for this, you can do this with vanilla Rails 2: User.active.construct_finder_sql...

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

Install libreadline: sudo apt-get install libreadline-dev Reinstall the ruby and tell rvm where to find readline

Put the following into config.ru in your Rails root folder: # Require your environment file to bootstrap Rails require ::File.dirname(__FILE__) + '/config/environment' # Dispatch the request run ActionController::Dispatcher.new Otherwise, your Rails...

iana.org

...decide to open a file directly instead of having to save it first. For Rails >= 3.2 Simply put your mime types in config/initializers/mime_types.rb. send_file will take care of everything...

For Rails < 3.2 Put your mime types in config/initializers/mime_types.rb. Additionally, tell send_file to use them (for example like this): file = @attachment.file.path file_extension = File.extname(file)[1..-1]

See our new comprehensive guide to upgrading every Rails 2 version ever...

See our new comprehensive guide for upgrading every Rails 2 version ever...

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"

JavaScripts and CSS should be minified for production use. In Rails 3.1+ the asset pipeline will take care of this. Thus you're best off using an uncompressed version of...

...be easier and you will still get all the minification love once deployed. In Rails 2.3 and 3.0 you should at least embed external JavaScript libraries in minified form, using...

...see below) -- but can be a problem, for example for the capture method of Rails. Consider these methods: def stuff puts 'yielding...' yield puts 'yielded.' true end

...have probably seen it before, e.g. a return in an each block. Impact on Rails applications Since this is something that you would have to do yourself, you could just...

In Rails 2, when calling instance_eval or instance_exec on a scope, the scope will fetch its records from the database. This has been fixed in Rails...