When using the asset pipeline your assets (images, javascripts, stylesheets, fonts) live in folders inside app: app/assets/fonts app/assets/images app/assets/javascripts app/assets/stylesheets With the asset pipeline, you can use the...

When you deploy, Rails runs assets:precompile which precompiles all assets into static files that live in public/assets. This way you have all the performance of static files...

makandra dev
github.com

SVG files are often much larger than necessary, containing comments, metadata, hidden elements etc. Optimize them with this tool. Web UI: https://jakearchibald.github.io/svgomg/ Binary: https://github.com/svg/svgo

...for a properly scaling SVG, you need to keep the viewBox attribute. There's an option --disable=removeViewBox for this...

tl;dr: Do not use merge! for session hashes. Use update instead. Outline Let's assume you're modifying the Rails session. For simplicity, let's also assume your session...

...is empty when you start (same effect when there is data): # In our example, we're in a Rack middleware request = Rack::Request.new(env) request.session.merge! :hello => 'Universe' request.session => {} Wat?

Ruby's standard library includes a class for creating temporary directories. Similar to Tempfile it creates a unique directory name. Note: You need to use a block or take care...

...of the cleanup manually You can create a prefix and suffix e.g. Dir.mktmpdir(['foo', 'bar']) => /tmp/foo20220912-14561-3g93n1bar You can choose a different base directory than Dir.tmpdir e.g. Dir.mktmpdir('foo', Rails.root.join('tmp...

makandra dev
semaphoreci.com

Capistrano 3 is a major rework of the framework and requires several adjustments to your deploy configuration files. The biggest change is that they moved away from their custom DSL...

...release_roles|...) :some_role do Resources Very helpful, leads you 90% of the upgrade: https://semaphoreci.com/blog/2013/11/26/capistrano-3-upgrade-guide.html Official documentation Many examples of SSHKit...

makandra dev
innig.net

...lambdas in Ruby work, check out the code at the attached link. Here the summary: ^ ---------------------------- Section 6: Summary ---------------------------- So, what's the final verdict on those 7 closure-like entities...

...method Y closure yes The things within each of these groups are all semantically identical -- that is, they're different syntaxes for the same thing: 1. block (called with yield...

...A minimum total number of forms (both blank and pre-filled) so the user sees more than just 2 blank Actor forms when she is entering Actors for the first...

...the number of total rows. By default there is no limit. You can also set defaults for built records by adding additional keys to the options hash: form.build_nested_records...

Middleman is a static page generator that brings many of the goodies that Rails developers are used to. Out of the box, Middleman brings Haml, Sass, helpers etc. However, it...

...these gems to the Gemfile: group :test do gem 'cucumber' gem 'spreewald' gem 'capybara' gem 'selenium-webdriver' # Only for running tests in a real browser (suggested) gem 'capybara-screenshot' # Optionally...

news.ycombinator.com

This is an extract from the linked article. It shows an approach on how to implement encrypted passwords with the AWS Key Management Service (KMS). For most applications it's...

...enough to use a hashed password with a salt (e.g. the gem devise defaults to this). Upon password creation Generate hash as hash of password + salt. Encrypt the hash with...

...Ruby parser module of Ruby-GetText comes across a file in one of its search directories (e.g. lib/scripts/) and finds out that you are defining ActiveRecord classes inside it, it...

...the whole file. Here is how to avoid that. What's happening? Let's say you have the following script which is only run once, manually, via script/runner: # lib/scripts/doomsday.rb

...you pin all "important" files, you can follow method definitions, wildly open files from search results and have a ton of open tabs -- without the problem of finding the stuff...

...tabs of files that are currently in the focus of your work (important models, specs, etc): Right-click a tab and select "Pin tab" Or use a shortcut (see below...

A datetime in MySQL does not have a zone. It just stores the literal string "2010-05-01 12:00:00". That means that Rails must make...

...mode Rails assumes that your application lives in the same time zone as your server's local zone settings. In this mode ActiveRecord will not try to convert times coming...

makandra dev

...use Solr by calling Article.search { fulltext(title) paginate(:per_page => limit) } Now look at http://sunspot.github.com/docs/ to learn about all the possibilities of Sunspot. Overwrite Sunspots' search method

...your SysOp team that you'll need Solr on staging and production, on Ubuntu the solr-common will provide what you need. First of all you should provide Solr with...

ActionMailer per default uses http as protocol, which enables SSL-stripping. When a logged-in user follows an http link to your application, it sends the cookies along with it...

...to send emails from public parts of your application with HTTP links and emails from SSL-protected parts with HTTPS, build a before_filter. If you need certain links with...

...It must be fixed by patching the Jasmine sources. Fix for Webpacker Add the package string-replace-loader to your package.json. If you're on Webpacker 5 (Webpack 4) the...

...your config/webpack/environment.js: environment.loaders.prepend('fix-jasmine4-global-detection', { test: /jasmine-core\/lib\/jasmine-core\/jasmine\.js$/, use: [{ loader: 'string-replace-loader', options: { search: 'window.toString() === \'[object GjsGlobal]\'', replace: 'window.toString() === \'[object Window]\'' } }] }) Fix for ESBuild...

makandra dev

We have released Modularity 2. It has many incompatible changes. See below for a script to migrate your applications automatically. There is no does method anymore We now use traits...

The script will rename your files and change your code. It will also syntax-check your files after conversion (since the script is not perfect). Check the diff...

Our CI setup frequently sees this error while running yarn install: yarn install v1.22.19 [1/4] Resolving packages... [2/4] Fetching packages... error An unexpected error occurred: "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz: unexpected end...

...here are some workarounds for Yarn 1. Increase Yarn's network timeout yarn config set network-timeout 600000 -g Retry yarn install until it succeeds The following will retry yarn...

These are the results of the "personal tech stack survey". I've included only the most popular mentions, maybe it can help you find one or two useful tools for...

...Command line UI for git. htop (10 users) An improved "top". fzf (8 users) Provides super-fast fuzzy-finding in various contexts (for example for shell command history).

Git allows you to set push options when pushing a branch to the remote. You can use this to build an alias that automatically pushes a branch and creates a...

...merge request for it. Put this in your ~/.gitconfig in the [alias] section: mr = push origin HEAD -o merge_request.create -o merge_request.draft Now you can do git mr and a draft...

...you, like a browser would (e.g. move block elements out of parents which are specified to not allow them). >> Nokogiri::HTML.fragment(" foo bar ").to_s => " foo bar "

...HTML. And you don't want to be the one to blame when the SEO folks complain about an empty . To avoid said behavior, use Nokogiri::XML instead of Nokogiri...

Rails 5.2+ supports "verbose query logs" where it shows the source of a query in the application log. Normally, it looks like this: User Load (0.5ms) SELECT "users".* FROM...

...app/controllers/users_controller.rb:42:in `load_users' However, you may encounter ActiveRecord's LogSubscriber as the source for all/most queries which is not helpful at all: User Load (0.5ms) SELECT "users...

thoughtbot.github.io

Let's say you have two factories that share some attributes and traits: FactoryBot.define do factory :user do screen_name 'john' email 'foo@bar.de' trait :with_profile do age 18 description...

age 18 description 'lorem ipsum' end end end You can re-use the shared fields by defining a trait outside the other factory definitions: FactoryBot.define do trait :person do...

dev.to

...alias such as this to your ~/.bashrc: alias recent-branch="git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ | fzf | sed 's/\* //g' | xargs -I '{}' git checkout {}"

Now whenever you want to switch back and forth between your most recent branches, type recent-branch, select one and press enter...

With ES2021 you now can use str.replaceAll(), Promise.any(), logical assignment operators, numeric separators and WeakRef on all major browsers except IE11. replaceAll JavaScript's replace(searchValue, replaceValueOrFn) by...

...default replaces only the first match of a given String or RegExp. When supplying a RegExp as the searchValue argument, you can specify the g ("global") modifier, but you have...