When you have two models in a has_many, has_one or belongs_to association, the :inverse_of option in Rails tells ActiveRecord that they're two sides of the...
...same association. Example with a has_many / belongs_to association: class Forum < ActiveRecord::Base has_many :posts, inverse_of: :forum end class Post < ActiveRecord::Base belongs_to :forum, inverse_of...
...either build a ES cluster or you disable the replicas. Building a cluster is beyond the scope of this card, but we can have a look how we can disable...
...localhost:9200/_cat/shards?pretty' | grep UNASSIGNED If it's a replica (r in the column befor the UNASSIGNED) and you are on a single node elasticsearch you need to disable replicas...
...confident about upgrading Rails, have a look at Rails LTS. How many update steps? Besides the Rails upgrade itself, you might also want to upgrade your other gems and upgrade...
...many cases updating to the highest subversion of the specific rails version is the best choice (e.g. when updating to rails 5 you would update to 5.2.8.12), since the most...
Exercise 1: Maps In MovieDB, add a new field “Principal filming location”. In a movie’s show view, geocode that...
...described above. legacy_transforms.rb This file adds a Transform method to the Cucumber "World" which behaves similar to the Cucumber 1 and 2 transformations. This allows cucumber_factory to keep using...
...like these before applying them to production. When entering these rules in the screen behind the Edit Test Rules button in the AWS console and testing it, the results section...
...number of options. Offers some pretty skins for downloading, but is hard to customize beyond that. SoundManager 2 Free. Only does audio. Awkward API. There seems to be no way...
...pre-existing mocks inside the block, they are not reverted to the previously mocked behavior. This is usually not relevant and you should be fine in most cases...
In Ruby, the meaning of protected and private is different from other languages like Java. (They don't hide methods...
In Ruby on Rails ActiveRecord::Relation#merge overwrites existing conditions on the same column. This may cause the relation to...
You can ignore certain commits when using git blame with the --ignore-revs-file option. This is handy to ignore...
...provide a lot of ways to style your scrollbars for now, it might be best to only use them in Browsers that don't support the non-standard scrollbar styling...
Here are some hints on best practices to maintain your tasks in larger projects. Rake Tasks vs. Scripts The Rails default is using rake tasks for your application tasks. These...
run_script(subject, 42, 'some_arg') assert_something end end Further reading Best practices: Writing a Rails script (and how to test it...
...fail with an SQL error due to duplicate index key. You can change Rails' behaviour, by saying class User < ActiveRecord::Base validates_uniqueness_of :name, case_sensitive: false end
Your package-lock.json should always match and resolve all packages from your package.json. Coming from Yarn, I was looking for an...
...sends out transactional e-mails to a large number of users, e-mail deliverability becomes an issue. E-mail providers work hard to eliminate spam and have put in place...
...No staging sandbox No permission system for api keys No authentication mechanism for webhooks besides IP ranges Buggy admin UI SendGrid Pro: Very good deliverability Not quite as expensive
...default: 3.0.1) It is still possible to have newer version of a gem installed beside the default version: gem install strscan Fetching strscan-3.0.3.gem Building native extensions. This could take a...
Starting with ChromeDriver 127, if your application displays a beforeunload confirmation dialog, ChromeDriver will immediately close it. In consequence, any automated tests which try to interact with unload prompts will...
...such dialogs. This means that we want to use the BiDi driver when testing beforeunload prompts. Enabling the BiDi WebDriver Using Capybara, simply set the :web_socket_url option to...
...i.e. one transaction can see most of what another is doing), and SERIALIZABLE the best (i.e. transactions are very well isolated). Conversely, READ UNCOMMITTED gives you the best performance, while...
...will be the slowest, due to a lot of locking. This also affects locking behaviour and replication performance. The default level is REPEATABLE READ, and it's the mode you...
Due to network or hardware failures, it can happen that one of your cronjobs will not run at the time...
...addresses = AddressBook.new addresses.add Contact.new(first_name: 'Frederik', last_name: 'Foo') addresses.add Contact.new(first_name: 'Berta', last_name: 'Beispiel', phone: '556677') addresses.add Contact.new(first_name: 'Anna', last_name: 'Muster', street: 'Foo...
...returns contacts that match all of the words in any property: results = addresses.search('77 berta') results.size # => 1 results[0].first_name # => "Berta" Errors Change the AddressBook class so the #add...
The recommended additional setup of the spreewald gem, a useful set of cucumber steps, includes adding a file for defining...
If you are using PDFKit / wkhtmltopdf, you might as well want to use custom fonts in your stylesheets. Usually this...
Greg Molnar has written a neat article about creating a single-file Rails app. This is not meant for production...