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...
While most Rails Apps are tied to at least one external REST API, machine-to-machine communication via GraphQL is less commonly seen. In this card, I'd like to...
...w[errors]) unless response.status.ok? parsed_response end def client headers = { 'Content-Type' => 'application/json', 'Authorization' => Rails.application.secrets.fetch(:linear_api_key), } HTTP.headers(headers) end end Writing data (Mutation) Performing GraphQL mutations is equally...
...in webpack.config.js: { ... optimization: { minimize: true, minimizer: [ new TerserPlugin({ terserOptions: { ..., mangle: { properties: { regex: /^[_#]/ } } } }) ] } } Configuring Webpacker (Rails) To configure Webpack to mangle private properties, make a change to your Terser configuration in...
With this command you can initiate an application restart without touching restart.txt. Unlike touching restart.txt, this tool initiates the restart...
...like above: new(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout') Difference between Rails mailer and ERB Rails mailer <% if true %> <%= 'bar' %> <% end %> <%= 'foo' %> <%= 'bar' %> bar foo bar
...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...
...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...
...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)
...an existing project Add: gem "reek", group: [:test, :development] To run Reek on your Rails project: $ bundle exec reek app lib config test This will check the existing code for...
...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...
...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.
...piece, but it should be tidy and clear. If you have generated styles from Rails scaffolding, delete them all. They don't look nice and we do not use them...
...framework, remove it and build your own styles from scratch. Tip Your MovieDB uses Rails 8 with esbuild. Sass support is already configured through the esbuild-sass-plugin library — there...
Put the line below in the respective env.rb file to make your action controllers raise an ActionController::UnpermittedParameters error when...
...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...
...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...
...classes — and when a project benefits from it. You can integrate Bootstrap into a Rails app from npm as Sass, without a CDN, and load only the parts you need...
...and don't want to depend on external sources. To integrate Bootstrap into your Rails application, install bootstrap npm package. Import Bootstrap's Sass code from your stylesheets.
...Probably the best approach is to just convert emails (and usernames) to lowercase within Rails. Popular authentication libraries (like Clearance and Devise) already do this for you...
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...
...exception notifications, and who reacts to them. You can integrate exception notification into a Rails app and verify it by triggering an error. You can explain what an error-monitoring...
...our card on integrating exception notification 📄 exception_notification — the gem's README 📄 Sentry for Rails — the official setup guide 📄 Controlling issue grouping in Sentry and deferring notifications for an issue...
...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...
...building it yourself Also see the chapter "Owning your Stack" in the book Growing Rails Applications in Practice. Services Open-Source Maturity & Maintenance Certification Rubygems
...an alternative to PostgreSQL fulltext search A simple example with a GIN index in Rails for optimizing a ILIKE query
...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...