Rails includes a way to see what an e-mail will look like. Integration to RSpec All you need to...
...to cancel event propagation, each with different semantics. event.preventDefault() Only prevents the default browser behavior for the click, i.e. going to a different url or submitting a form.
...the class including the trait. While this may seem unproblematic at first glance, it becomes a problem when including traits in multiple classes, especially when using parameterized traits.
...you are actually defining ExampleTrait::HELLO. If you want to define a constant that belongs to a trait module, you can do that, and there a valid reasons to do...
Text fragments allow linking directly to a specific portion of text in a web document, without requiring the author to...
You can share a state in Ruby with global variables. Even if you should avoid them whenever possible, for debugging...
If you are using git submodules in Gitlab CI, you might run into a "The project you were looking for...
Sometimes you want to fetch associations for an ActiveRecord that you already loaded, e.g. when it has deeply nested associations...
In the past we validate and set default values for boolean attributes in Rails and not the database itself.
...holds your bash prompt. You might want to change it to serve your needs best. Here is how to: General non-printing escape sequences in your prompt have to be...
Phusion Passenger changed the way how it gets restarted several times. Through the project's history, these all were valid...
When your controller action raises an unhandled exception, Rails will look at the exception's class and choose an appropriate...
...an integer with a string without explicit casting. Related security issue In authentication, this behavior may be used to match rows without knowing a secret token: Potential Query Manipulation with...
From Exploring ES6: Module imports are hoisted (internally moved to the beginning of the current scope). Therefore, it doesn’t matter where you mention them in a module and the...
Recent rails security updates have shown that people make incorrect assumptions about the possible contents of the params hash.
Understanding your type of cronjob Some cronjobs must only run on a single server. E.g. when you run nightly batch...
...Gemfile.lock carefully when submitting a commit. Note that the approach in this card works best, if you use bundle outdated together with bundle update some_gem --convervative for major updates...
...methods for calculating times and dates, like Duration#ago or Duration#from_now. But beware when using those, because they wont give you Dates or Times but ActiveSupport::TimeWithZone instances...
...your local timezone, but Rails.application.config.time_zone, which has UTC as default value. The mitigation Best case, you have already defined Rails.application.config.time_zone, as we recommend anyway. In this case you...
Today I got a better understanding of how git works, in particular what git checkout and git reset do. Git basics A commit holds a certain state of a directory...
The linked article suggests an interesting way to speed up tests of Rails + Postgres apps: PostgreSQL allows the creation of...
Working with a self-signed certificate is much easier, when the browser accepts it. Google Chrome Warnings from chrome might...
...accept both optional and keyword arguments is dangerous and should be avoided. This confusing behavior will be deprecated in Ruby 2.7 and removed in Ruby 3, but right now you...
end end colored_p(User.new) # ArgumentError: unknown keywords: first_name, last_name This behavior is not very smart. The easy fix is just to never mix optional and keyword...
PostgreSQL uses the C library's locale facilities for sorting strings: First, all the letters are compared, ignoring spaces and...
...not do that and if everything was fine before, maybe just restore the previous behavior by adding environment.loaders.delete('nodeModules') to your environment.js. If you used postcss-cssnext before, add it...
By default, Devise sends all emails synchronously with deliver_now. To change that, Devise's readme suggests overwriting the send...