makandra dev

To ensure Spring is not running: bin/spring stop pkill -f spring To prevent Spring from starting again: export DISABLE_SPRING...

} } } } } Integration in Rails + searchkick Was benötigt man für Integration von Elastic in eine Rails-Anwendung? Mindestens: Client um mit Elastic zu reden Erzeugen von Indexen, passender Mappings + Migration...

paweldabrowski.com

The linked content includes a few design patterns implemented with Ruby on Rails. What is the card indented to achieve? You can use the pattern names for code reviews, so...

Sometimes you want to have a time in a given timezone independent from you Rails timezone settings / system timezone. I usually have this use case in tests. Example

...return different results e.g. 2020-08-09 00:00:00 +0200 depending on the Rails timezone settings / system timezone. But in this example we always want to have the given...

Rails defines a #truncate helper as well as a method String#truncate. = truncate("my string", length: 5) = "my string".truncate(5) Both are really similar; in fact, the helper invokes...

dev.37signals.com

The author describes his little journey in hunting down a memory leak. Maybe his approach and tooling may one day...

stackoverflow.com

Create, or edit your ~/.irbrc file to include: require 'irb/ext/eval_history' # was 'irb/ext/save-history' for versions prior to Ruby 3.3 IRB.conf[:SAVE...

When logging in Rails, you can use the log_tags configuration option to add extra information to each line, like :request_id or :subdomain. However, those are only valid inside...

...log entries which are mixed together. Welcome to debugging hell. You want something like Rails' :request_id tagging. This can easily be achieved through a Sidekiq middleware as follows.

...find out which parts of your application are not tested. Integrating this in a rails project with rspec, cucumber and parallel_tests is easy. Add it to your Gemfile and...

...gem 'simplecov', require: false end Add a .simplecov file in your project root: SimpleCov.start 'rails' do # any custom configs like groups and filters can be here at a central place...

...concept worked really good. Here are two points that were extraordinary compared to normal Rails project with many UI components: Having a Rails application, that has no UI components (only...

...to look up different before you need to integrate an API component into your Rails application. REST API vs. GraphQL It is worth to consider whether you want to have...

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...

...While there was an issue back in 2018 which can be resolved by upgrading Rails, this also happens when ActiveSupport's BacktraceCleaner is configured to not hide gems from the...

makandra dev
github.com

...Gruff for easily plotting graphs. It is written in pure Ruby and integrates with Rails applications. It provides features as automatic sizing of dots and lines (the more values, the...

...restart your development server.) Usage This is a common example for graph generation in Rails. Note that you have many configuration options at hand that are not documented. Github and...

tl;dr: Upgrade the gem to at least 4.0.1 When you use rspec_rails in a version < 4 with Rails 6.1 you may encounter an error like this: Failure/Error:

...expect(actor).to be_valid end end But the error came from rspec_rails itself. I found this issue on GitHub, which is solved in rspec_rails 4.0.1.

If you use webpacker in your Rails application, and you have completely disabled Sprockets, you might get the following error when trying to deploy: Rails assets manifest file not found...

...This happens inside the deploy:assets:backup_manifest task. This task comes from capistrano-rails. It is build for Sprockets and does not work with Webpacker out of the box...

You can use record.send(:update_without_callbacks) or record.send(:create_without_callbacks) This can be used as a lightweight alternative to machinist's make or FactoryGirl's create...

...return the object, so you might want to do record = Record.new.tap(&:create_without_callbacks) Rails 3 Rails 3 no longer comes with update_without_callbacks or create_without_callbacks. There...

Rails supports alert and notice as default flash types. This allows you to use these keys as options in e.g. redirect_to and as a helper in views e.g. <%= notice...

makandra dev

To offer files for download, use send_file. def download(file) send_file file.path, :disposition => 'attachment' end

...has to wait until the thread of one of the workers is free. Threads Rails is thread-safe since version 4 (note that not all gems are thread-safe). This...

...for the related config/puma.rb: workers Integer(ENV['WEB_CONCURRENCY'] || 2) threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) Note: Having multiple workers in development and tests might cause unexpected issues...

It sometimes happen that a database dump, that would want to insert into your development database, does not match the...

...development, you might get an ActiveRecord::EnvironmentMismatchError when trying to replace the database (like rails db:drop, rails db:schema:load). $ rails db:drop rails aborted! ActiveRecord::EnvironmentMismatchError: You are...

...sure you want to continue, first set the environment using: bin/rails db:environment:set RAILS_ENV=development Starting with Rails 5, the ar_internal_metadata database table was introduced:

You might have some trouble running a Rails LTS 2 app with MySQL 5.7. If you don't want to hack Mysql 5.6 into your modern Ubuntu or use the...

...try MariaDB 10.x. MariaDB 10.x should work with both old and new Rails applications. Switch to MariaDB Remove MySQL: sudo apt remove mysql-common mysql-client mysql-server...

makandra dev
medium.com

In Ruby on Rails, all the routes of a given application can be found within the config/routes.rb file. You add more and more routes in this file as your project...

...important to find a way to order and maintain your routes. See: Clean your Rails routes: grouping Sometimes the routes.rb grows very fast and each line adds more confusion to...

...reload the page, log into the site and reload the cookie information site. For Rails powered sites, you should see a cookie named '_your_site_session' and -- depending on your...

When working with times and dates in Rails applications, you need to deal with the following problem: In Rails, Time objects have a time zone. You can get the zone...

...just stores the literal string "2010-05-01 12:00:00". That means that Rails must make assumptions about timestamps loaded from and written to MySQL. Rails has two completely...