tl;dr: Upgrade the gem to at least 4.0.1 When you use rspec_rails in a version < 4 with Rails 6.1 you may encounter an error like this: Failure/Error:
...expect(actor).to be_valid end end But the error came from rspec_rails itself. I found this issue on GitHub, which is solved in rspec_rails 4.0.1.
...and install RubyGems yourself. Install Bundler sudo gem install bundler Put bundler on a Rails 2.3 project Follow the instructions on bundler.io You should have patched your boot.rb
...reads Gemfile and builds Gemfile.lock with all dependencies etc. If you see "Missing the Rails 2.3.8 gem." you forgot to bundle Rails. If you see "Missing the mysql gem", bundle...
Rails 5.2+ supports "verbose query logs" where it shows the source of a query in the application log. Normally, it looks like this: User Load (0.5ms) SELECT "users".* FROM...
...While there was an issue back in 2018 which can be resolved by upgrading Rails, this also happens when ActiveSupport's BacktraceCleaner is configured to not hide gems from the...
The Rails logger will store its content in a buffer and write it into the file system every 1000 lines. This will come back to bite you when using Rails.logger.info...
...environments auto_flushing is set to write after each line. On production environments the Rails logger writes only every 1000 lines -- and not upon shell or script termination as you...
To offer files for download, use send_file. def download(file) send_file file.path, :disposition => 'attachment' end
If you use webpacker in your Rails application, and you have completely disabled Sprockets, you might get the following error when trying to deploy: Rails assets manifest file not found...
...This happens inside the deploy:assets:backup_manifest task. This task comes from capistrano-rails. It is build for Sprockets and does not work with Webpacker out of the box...
You might have some trouble running a Rails LTS 2 app with MySQL 5.7. If you don't want to hack Mysql 5.6 into your modern Ubuntu or use the...
...try MariaDB 10.x. MariaDB 10.x should work with both old and new Rails applications. Switch to MariaDB Remove MySQL: sudo apt remove mysql-common mysql-client mysql-server...
...the same routes, the controller paths will be different, though. In the first example rails will expect to find a Users::SignUpsController in the subdirectory controllers/users/sign_ups_controller.rb, but there has to...
...first example of this card (resource :report, only: :show, controller: 'projects/report'). Solution for legacy Rails versions What you can do instead is simple re-use the :projects symbol as both...
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...
Rails supports alert and notice as default flash types. This allows you to use these keys as options in e.g. redirect_to and as a helper in views e.g. <%= notice...
...prevent this, test for the right environment and place the JS-code afterwards: - if Rails.env.production? :javascript var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']); _gaq.push(['_trackPageview...
See our new comprehensive guide for upgrading every Rails 2 version ever...
See our new comprehensive guide to upgrading every Rails 2 version ever...
If you get an error like this ... can’t find executable rails for rails-3.2.3 (Gem::Exception) ... one of several things might be wrong. You're using RVM
...possible that you have a system-wide gem executable (like rails) that requires a gem that is not available in the current RVM Ruby or gemset. Check what Ruby you...
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...
Note that this seems to affect only recent Rails 2 versions. You will not encounter this until you are writing to the cookie more than once, but when doing so...
Solution This seems to be a bug in Rails, the CookieStore (for sessions) or Rack::Utils.set_cookie_header -- I did not bother looking closer. My problems went away...
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...
...development, you might get an ActiveRecord::EnvironmentMismatchError when trying to replace the database (like rails db:drop, rails db:schema:load). $ rails db:drop rails aborted! ActiveRecord::EnvironmentMismatchError: You are...
...sure you want to continue, first set the environment using: bin/rails db:environment:set RAILS_ENV=development Starting with Rails 5, the ar_internal_metadata database table was introduced:
You may encounter problems with passenger starting an application with an updated rails. If you find an error like this in the apache error log...
...17680/7f4907ae7700 agents/HelperAgent/RequestHandler.h:2210 ]: [Client 19] Cannot checkout session. Error page: This application is a Rails 3 application, but it was wrongly detected as a Rails 1 or Rails 2 application...
A couple of Railsconfs ago, Courtenay and I did indeed discuss
...an API which you could maybe use! You can connect to the GitLab internal Rails with executing gitlab-rails console. It might be slow at times, especially if you use...
The following code listings are expected to be entered inside the gitlab-rails console. Remove GitLab Labels from already closed Issues p = Project.find_by_id(1)
...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...
...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...
...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...