axonflux.com

Here is a set of additive color model conversion algorithms that I found published on Wikipedia and have implemented in...

robots.thoughtbot.com

We recently decided our CI server needed an overhaul. I really enjoyed Integrity as a build server, but after trying...

gusiev.com

What do we expect from the custom finder? We expect that it should find assets A, B, C and should...

apidock.com

All ActiveRecord associations except for has_many :through support callbacks for pre- and post-insertion/deletion via the following, self...

...and decide if any of it needs an update. Your main components (e.g. Ruby, Rails, Unpoly) should always be reasonably up to date. Keeping your dependencies up-to-date is...

...a lib/ext/super_client.rb to your project (see How to organize monkey patches in Ruby on Rails projects) Add the extension, which overrides both methods (prepend is available since Ruby >=2) # lib/ext/super_client.rb...

...can define the vcr: true hook yourself: # spec/support/vcr.rb VCR.configure do |c| c.cassette_library_dir = Rails.root.join("spec", "vcr") c.hook_into :webmock end RSpec.configure do |c| c.around(:each, :vcr) do |example|

...users.map { |user| [user.id, user.name] }.to_h { 1 => "Alice", 2 => "Bob" } Enumerable#index_by (any Rails version) users = User.all users_by_id = users.index_by(&:id) { 1 => #<User id: 1, name: "Alice...

...User id: 1, name: "Alice">], "Bob" => [#<User id: 2, name: "Bob">] } Enumerable#index_with (Rails 6+) To generate a hash where array elements become hash keys, and values are calculated...

job_id: job.job_id, executions: job.executions, queue_name: job.queue_name, url: url, }, ) end Rails.application.configure do # Also capture errors not handled by Active Job config.good_job.on_thread_error = ExceptionNotifier.method(:notify_exception...

makandracards.com

In medium-sized to large Rails applications, asset compilation can take several minutes. In order to speed up deployment, asset precompilation can be skipped. This card automates the process.

kernel.org

...mind that you may need to migrate your database as Git is unaware of Rails and will not cast any magic. If Git checked out a commit that is working...

...the sudo password with johndoe ALL=(ALL) NOPASSWD: ALL. # Run this script with e.g. `rails runner lib/scripts/benchmark.rb` require 'open3' # For debugging # Rails.logger = Logger.new(STDOUT) # ActiveRecord::Base.logger = Logger.new(STDOUT)

With this command you can initiate an application restart without touching restart.txt. Unlike touching restart.txt, this tool initiates the restart...

...you're done, check your changes by running rake routes. handle_unverified_request When Rails gets a request with wrong/missing CSRF-Token, it calls ApplicationController#handle_unverified_request and continues...

...processing the request!. Per default, the method only resets the Rails session, but since Clearance doesn't store its session there, you should delete the remember_token cookie. With Clearance...

...this requires the PP class from the pp gem. It is loaded in any Rails app already, but for plain Ruby you may need to require it.

...are libraries like morphdom (as used by Phoenix Liveviews) or idiomorph (as used by Rails' Turbo). It lets you write morphdom(node, newHtml) or Idiomorph.morph(node, newHtml) which will try...

...issues in specific scenarios. Why does this matter? Mocked time in tests Consider a Rails application where you use the remember_me feature of Clearance for authentication. The cookie for...

This is quite an edge case, and appears like a bug in Rails (4.2.6) to me. Update: This is now documented on Edgeguides Ruby on Rails: If you set the...

...resources. The spec looks very similar to how one would build an API with Rails and uses similar patterns. Even if you don't plan on supporting the whole spec...

...they won't change their mind. [1] We are not talking about the the Rails session hash here, although it is by default backed by a cookie without expiration...

...not rendered in controller specs. If you need it to happen, use: RSpec 1 (Rails 2): integrate_views RSpec 2 (Rails 3): render_views Note that you can't use...

...feature-binaries commit id: "docs" commit id: "add binaries" type: HIGHLIGHT commit id: "init rails" You are now asked to split up the add binaries commit to one commit per...

...id: "echo binary" type: HIGHLIGHT commit id: "curl binary" type: HIGHLIGHT commit id: "init rails" Exercise 3: Rebase onto a diverged feature branch with merge conflicts %%{init: { 'gitGraph': { 'mainBranchName': 'master...

...a command on all servers. bundle exec cap production app:run cmd='zgrep -P "..." RAILS_ROOT/log/production.log' Code # lib/capistrano/tasks/app.rake namespace :app do # Use e.g. to grep logs on all servers:

...cap production app:run_cmd cmd='zgrep -P "..." RAILS_ROOT/log/production.log' # # * Use RAILS_ROOT as a placeholder for the remote Rails root directory. # * Append ` || test $? =1;` to grep calls in order...

Put the line below in the respective env.rb file to make your action controllers raise an ActionController::UnpermittedParameters error when...