In case you want to use pry with an older version of Ruby, you can try the following configurations.
pry version must not be greater than
gem 'pry', '=0.9.10' gem 'ruby-debug' gem "ruby-debug-pry", :require => "ruby-debug/pry" gem 'pry-nav' gem 'ruby18_source_location'
pry version must not be greater than
gem 'debugger', '=1.1.4' gem 'pry-debugger', '=0.2.0' gem 'pry', '=0.9.9'
An unresponsive service can be worse than a down one. It can tie up your entire system if not handled properly. All network requests should have a timeout.
Here’s how to add timeouts for popular Ruby gems. All have been tested. You should avoid Ruby’s Timeout module. The default is no timeout, unless otherwise specified. Enjoy!
Rails 5.1+ projects often use Webpacker to preconfigure the Webpack pipeline for us. The default configuration works something like this:
We use CarrierWave in many of our projects to store and serve files of various formats - mostly images. A common use case of CarrierWave's DSL is to "process" the original file in order to create multiple "versions", for example different resolutions of the same image.
Now we could go one step further: What if we want to create versions that have a different file extension than the original file? For example, let's assume we'd like to create a ve...
if 'foo' =~ /foo/ puts $~ # => foo end
if 'foo' =~ /foo/ puts $LAST_MATCH_INFO # => foo end
The English library is not loaded by default in Rails. S...
When working with times and dates in Rails applications, you need to deal with the following problem:
Timeobjects have a time zone. You can get the zone name by doing
Rails has two completely different modes ...
This card describes how to install some tasks only for a given Rails environment or for a given Capistrano stage.
bundle update GEMNAME will update a lot more gems than you think. E.g. when you do this:
bundle update cucumber-rails
... you might think this will only update
cucumber-rails. But it actually updates cucumber-rails and all of its dependencies. This will explode in your face when one of these dependencies release a new version with breaking API changes. Which is all the time.
In the example above updating
cucumber-rails will give you Capybara 2.0 (because
capybara is a dependency of `cucumber-rail...
Updated card to use
Bundler.with_original_env which is what you actually always wanted.
Also added a note on what
with_clean_env on legacy versions) does.
We released two new versions of Geordi. For projects with Ruby 1.8.7 or 1.9.3 you now have to run
gem install geordi -v '~>2' to get a compatible version.
RAILS_ROOT. This allows you as a gem developer to run a command like
RAILS_ROOT=~/Projects/my-blog geordi console stagingwhereas
geordiuses the capistrano config from
my-blog. Otherwise you would need to follow the instructions of [th...
You can install rubygems
3.0.8 (released on February 18, 2020) to keep all the
Gem::Specification#rubyforge_project deprecation warnings away from your development log. With Rubygems >=
3.1 this deprecation warning was introduced. While maintaining older projects this could get quite annoying and the fix below might okey, for newer projects the right ways is to upgrade the gems.
gem update --system 3.0.8
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed o...
You can run bundle install in parallel. This might be helpful for development, where you often install many new gems when switching between projects.
8with your number of proccessors):
bundle config jobs 8
Note: If you suspect parallel execution for bundling issues, you can try serially with
bundle install --jobs 1.
The linked GitHub repository is a bit like our "dev" cards deck, but groomed from a single person (Josh Branchaud). It includes an extensive list of over 900 TILs on many topics that might be interesting for most of us. (e.g. Ruby, Rails, Git, Unix..)
Here is an excerpt of all the Ruby TILs that were new to me. I encourage you to take your time to skim over the original list as well!
puma you can have concurrent requests. There are two concepts on how Puma can handle two incoming requests: Workers and Threads.
Puma can have multiple workers. Each worker is a process fork from puma and therefore a very heavy instance and can have multiple threads, that handle the incoming requests.
Example: A Puma server with
2 workers and
1 thread each can handle
2 request in parallel. A third request has to wait until the thread of one of the workers is free.
Rails is thread-safe since version 4 (n...
Simplecov is a code coverage tool. This helps you to 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 bundle
group :test do gem 'simplecov', require: false end
.simplecov file in your project root:
SimpleCov.start 'rails' do # any custom configs like groups and filters can be here at a central place end
You can use local copies of gems in your
Gemfile like this:
gem 'spreewald', :path => '~/gems/spreewald'
As soon as you have bundled your project with the local copy of the gem, all code changes in the copy will be available on your project. So you can for example set a debugger or add console output in the gem and use it from your project.
If you checked out the gem with your versioning tool, you can easily reset your changes afterwards or make a pull request for the gem if you improved it.
Don't commit a Gemfile with local pat...
Embedding videos on a website is very easy, add a
<video> tag to your source code and it just works. Most of the time.
The thing is: Both the operating system and Browser of your client must support the container and codecs of your video. To ensure playback on every device, you have to transcode your videos to one or more versions of which they are supported by every device out there.
In this card, I'll explore the available audio and video standards we have right now. The goal is to built a pipeline that transcodes unknown ...
Rails applications and ruby gems should have a README that gives the reader a quick overview of the project. Its size will vary as projects differ in complexity, but there should always be some introductory prose for a developer to read when starting on it.
That's already the main purpose of a project README: Give a new developer a quick overview of the project. In sketching this outline, the README should notify the reader of any peculiarity he needs to know of.
Remember that in a few months, you'll be a kind of "new ...