...no longer recommend this option. After a chrome update, the chromedriver package sometimes lags behind and is not compatible. Install via apt install chromium-chromedriver Option 3: Install via npm...
...no longer recommend this option. After a chrome update, the chromedriver package sometimes lags behind and is not compatible. There's a handy npm package. sudo npm -g install chromedriver...
It might sometimes be useful to check whether your Rails application accesses the file system unnecessarily, for example if your...
When selecting records in a date range, take care not to do it like this: start_date = Date.parse('2007-05...
When a user shares your content, a snippet with title, image, link and description appears in her timeline. By default...
Sometimes you need to remove high Unicode characters from a string, so all characters have a code point between 0...
has_many :images, through: :album_images end # Join model class AlbumImage < ActiveRecord::Base belongs_to :album belongs_to :image end Destroying a record in this setup will only remove...
...the record itself, and leave orphaned join records behind. image = Image.last image.destroy # removes only the `image` record, # but none of the associated `album_image` join records Good
You can convert git commits into patch files. Those can be used to apply to a different repository [1] or...
To retrieve only unique combinations of the selected attributes: You can omit rows, where all selected columns are equal with...
Note netstat has mostly been superseeded by its more modern rewrite ss which nowadays comes pre-installed rather than netstat...
You cannot use Array#join on an array of strings where some strings are html_safe and others are not...
...rendering quality is now fine in recent versions of wkhtmltopdf (0.12+). You will never beat LaTeX if you need perfect font rendering. If you are observing strange behavior when including...
...might experience that your application "locks up" whenever you request a .pdf route. This behavior is caused by a deadlock: The Rails process is trying to render the page to...
...won't need this for single lines of text. In this case it is better to just use the text-overflow property: Use CSS "text-overflow" to truncate long texts...
...starts wrapping within its container. This is most probably because there is no defined behavior in case multiple text contents are rendered next to each other (horizontally) and the clamping...
This is a small example on how you can check if your Postgres index can be used by a specific...
Developing or debugging SAML functionality can be a hassle, especially when you need to go back and forth with someone...
def self.acquire(name) already_acquired = definitely_acquired?(name) if already_acquired yield else begin create(:name => name) unless find_by_name(name) rescue ActiveRecord::StatementInvalid # concurrent create is okay...
begin result = nil transaction do find_by_name(name, :lock => true) # this is the call that will block acquired_lock(name) result = yield end result ensure maybe_released_lock...
For webpages to load fast it's recommended to optimize images. Ideally an image's file size should be as...
Why secure-only cookies used to be necessary Cookies have an optional secure flag. It tells the browser to not...
...used when you are working on a branch and make a new commits which belongs to a previous commit. If the previous commit is the last commit, you can also...
Even though the process in #1 could be used for this it can become quite tedious if you have a large commit and might have already done this and...
Is your application doing something expensive every few seconds? Maybe an animated slider that rotates images? Maybe you are updating...
In a project team for a bigger project people have several roles: Developer: at makandra Project lead: at makandra
This still relies on params[:id] existing, so your code should reflect that: # Better User.find(params.expect(:id)) # Or User.find(params.require(:id)) Avoiding issues with extra parameters Rails logs extra...
...should still use permit (or expect) to receive Strong Parameters, but strip extra parameters. # Better (option 1) redirect_to users_path(params.slice(:query, :encoding).permit(:query, :encoding)) # Better (option...
When you want to group rails models of a logical context, namespaces are your friend. However, if you have a...
ActiveSupport (since 4.1) includes test helpers to manipulate time, just like the Timecop gem: To freeze the current time, use...
You want to use fields in your applications. However, your desktop users may encounter some weird quirks: Aside from allowing...