...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...
Most forms have a single submit button that will save the record when pressed. Sometimes a form needs additional submit...
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...
Developing or debugging SAML functionality can be a hassle, especially when you need to go back and forth with someone...
The DB schema is the most important source of truth for your application and should be very self-explanatory. If...
...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...
Why secure-only cookies used to be necessary Cookies have an optional secure flag. It tells the browser to not...
When selecting records in a date range, take care not to do it like this: start_date = Date.parse('2007-05...
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
...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...
You can convert git commits into patch files. Those can be used to apply to a different repository [1] or...
Note netstat has mostly been superseeded by its more modern rewrite ss which nowadays comes pre-installed rather than netstat...
This is a small example on how you can check if your Postgres index can be used by a specific...
In a project team for a bigger project people have several roles: Developer: at makandra Project lead: at makandra
For webpages to load fast it's recommended to optimize images. Ideally an image's file size should be as...
...addition of both margins takes place but the maximum of both is applied. This behavior is called collapsing margins. Oftentimes it is a good behavior but collapsing margins can be...
...the previous sibling of the parent box. Nevertheless there are some exceptions where the behavior of vertical collapsing margins is not used. Exceptions when margins do not collapse
You want to use fields in your applications. However, your desktop users may encounter some weird quirks: Aside from allowing...
...for Structs are temporary data structures which just hold state and don't provide behaviour. In many cases you could use a simple hash as a data structure instead. However...
...are incredibly fast. If you have to handle lots of data it may be better to use hashes for performance reasons, even if the readability of the code suffers compared...
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...
We have now updated/created two gems that implement the requirements above using the best practices we know of: assignable_values: ActiveRecord macro to restrict the values that may be...
...feature of Bundler. It might be an unintended side effect of something else. I believe this command will try to update GEMNAME and GEMNAME only. If this leads to unmatched...
When you want to group rails models of a logical context, namespaces are your friend. However, if you have a...
It's 2024 and we have tools like ffmpeg, imagemagick and GPT readily available. With them, it's easy to...