...repositories. It's basically "Open Source Development 101". Way back in mid-2007, when Rails 1.2 was the new hotness and GitHub was still a year away from crawling out...
Looks simpler than inaction_mailer: gem install mailcatcher mailcatcher Setup Rails to send mails to 127.0.0.1:1025. Usually you want the following config in config/environments/development.rb and maybe in test.rb or...
...you really want to manage Example One example is used by us in environments::railscomplete::dbcollector: $vhost_types = ['\'Environments::Elixir::Vhost\'', '\'Environments::Rails::Vhost\'', '\'Environments::Php::Vhost\'', '\'Environments::Python::Vhost...
...query("resources {type in ${vhost_types} and parameters.dbbackend = '${dbbackend}'}") $vhosts.each |$vhost| { ensure_resource('environments::railscomplete::db', $vhost['parameters']['dbuser'], { 'password' => $vhost['parameters']['dbpassword'], 'type' => $type, 'extensions' => $vhost['parameters']['dbextensions'], 'schemas...
Rails 6.1 has a "strict loading" mode that forces the developer to preload any association they plan to use. Associations no longer load lazily. An error is raised when reading...
...on to the console IRB. console command: Ctrl + C now properly exits a local Rails console rspec and cucumber commands: Run specs even if the automatic chromedriver update fails
Note that you cannot currently use Ruby 1.9.2 with Rails 2 applications that use RSpec, so don't upgrade if that is your setup. The rspec-rails gem has a...
...fatal bug that was only fixed for rspec-rails-2.x, which only supports Rails 3. There is no fix for the rspec-rails-1.3.x series of the gem...
...our output will be more verbose than when we only need support modern browsers. Rails 5.1+ projects often use Webpacker to preconfigure the Webpack pipeline for us. The default configuration...
...Follow the instructions in the README. Most likely you want: to add the Ruby, Rails and RSpec cops to include the unit test 2. Report all existing offenses and exclude...
...TILs on many topics that might be interesting for most of us. (e.g. Ruby, Rails, Git, Unix..) Ruby Here is an excerpt of all the Ruby TILs that were new...
...mocked with Timecop. To integrate those two, we include and activate timemachine.js in our Rails layout whenever we see that Timecop is mocking the time: - if defined?(Timecop) && Timecop.top_stack...
...code is causing an exception which is not the one shown in your terminal. Rails tries to catch this exception and clean up constants but -- while it's still booting...
Have a look at the environment's log file instead Open up a Rails console (may give you more information than the logs) If you're lucky it's...
Rails comes with a Rake task notes that shows code comments that start with "TODO", "FIXME", or "OPTIMIZE". While it's generally not good practice to leave them in your...
app/helpers/frontend/slider_helper.rb: * [48] [TODO] this is only temporary till frontend is done However, with Rails' default configuration this task will only look through default file extensions, like .rb, .erb, .css...
...for easily adding new commands many little niceties New commands setup: set up a Rails project for the first time (bundle install, create database.yml, create databases, migrate), optionally run all...
...update by pulling/pushing/merging and deploying just as our workflow is devserver: boot a development server Rails-version-agnostic console: open a local Rails console Rails-version-agnostic, or remotely, e.g...
...image running the headless Chrome (e.g. chrome:4444) The integration test is testing a Rails application (but it could be any other application, too) Start your integration test docker container...
...is to "vendor" the gem by copying it into the vendor/gems directory of your Rails project. You can then make any changes you require and Rails will use the vendored...
...after a server restart. Unfortunately you need to perform some additional steps to marry Rails and the copied gem. This notes describes what to do. With Bundler
...object-oriented scripting language Ruby rubymine 2018.3.2 jetbrains✓ classic The Most Intelligent Ruby and Rails IDE ... Switch channel and install most recent version: $ sudo snap refresh rubymine --channel=2018.2/stable...
...Stefan', color: 'red'} ] names = users.collect do |user| user[:name] end If you're using Rails 5+, this example is covered by Enumerable#pluck (users.pluck(:name)). But with a little extension...
tl;dr: Always have your attachment path start with :rails_root/storage/#{Rails.env}#{ENV['RAILS_TEST_NUMBER']}/. The directory where you save your Paperclip attachments should not look like this: storage/photos/1...
...storage/test/photos/1/... storage/test/photos/2/... storage/test/attachments/1/... storage/test/attachments/2/... storage/test2/photos/1/... storage/test2/photos/2/... storage/test2/attachments/1/... storage/test2/attachments/2/... In order to implement this, make Rails.env and ENV['RAILS_TEST_NUMBER'] part of your path template: has_attached_file :attachment, :path...
...up on the disk check table sizes by disk usage instead. Connect to a Rails database with bin/rails dbconsole -p...
Your after_commit callbacks will not know about changes, as Rails discards them when committing. The linked article shows a clever trick to work around that: It uses an after...
...commit, and not after_save. Enqueueing a Sidekiq job is just one of them. Rails 5+ You can use saved_change_to_attribute? and previous_changes[:attribute] in after_commit...
Test one codebase against multiple sets of gem dependency sets (e.g. Rails 4.2, Rails 5.0). Test one codebase against multiple Ruby versions (e.g. Ruby 2.1.8, Ruby...
...possible dependency permutations (Ruby, gem set, database type). Manually exclude incompatible dependency permutations (e.g. Rails 5.0 does not work with Ruby 2.1). Let developers enter their local credentials for MySQL...
...them, this is fortunately made very easy if you use compass. Simple example for Rails 3+ Let's assume you have two images app/assets/images/layout/blue-button.png, and .../blue-button-hover.png and the following sass...
...not there already, add this to the :assets group in your Gemfile: gem 'compass-rails' gem 'oily_png' Run bundle install. Add a config/compass.rb with the following content:
...see below) -- but can be a problem, for example for the capture method of Rails. Consider these methods: def stuff puts 'yielding...' yield puts 'yielded.' true end
...have probably seen it before, e.g. a return in an each block. Impact on Rails applications Since this is something that you would have to do yourself, you could just...
...use the String#strip_heredoc method from ActiveSupport. See Summarizing heredoc in ruby and rails for an example. Technically, it looks for the least indented line in the whole string...