Defining one callback several times in the same class behaves different in ActiveRecord and ResourceController. While in ActiveRecord the callbacks are enqueued, they overwrite each other in ResourceController. ActiveRecord - a...
class Post < ActiveRecord::Base does 'post/behavior' before_validation :do_something end module Post::BehaviorTrait as_trait do before_validation :do_something_else end end do_something_else and do...
You're using exception_notification and want to send exception mails within a model. Here's how. The ExceptionNotifier class...
If your application raises an error like ... Couldn't connect to the Solr server at http://127.0.0.1:8983/solr. 500 "Lock...
>> ?> errors => {:base=>["foo", "bar"]} If you need to hack anything with these errors, beware that it behaves in a special way. If you iterate over the errors it will...
When you just went through a long debug-fest and infested your code with dozens of debug messages, it can...
At makandra we made a choice to use bower-rails instead. While we believe Rubygems/Bundler to be superior to Javascript package managers, we wanted to use something with enough...
...community momentum behind it that it won't go away in 10 years. Mixing Rails Assets with other Javascript sources Note that you can get into trouble when you mix...
If you are connected with a network that forbids e-mail traffic but allows SSH, you can tunnel your e...
If you get a Quota error with OpenStack, it doesn't have to be what it tell. For example, I...
When updating WebMock, be prepared that your specs may send real requests into the depths of the internet unless you...
The Angular ngSrc directive serves to properly set an image src via Angular. As anything in Angular, it updates the...
Let's say you have two XML strings that are ordered differently but you don't care about the order...
ActiveSupport::Memoizable will be removed from Rails and has a lot of strange caveats that will ruin your day.
has_many :users end class User < ActiveRecord::Base validates_presence_of :group_id belongs_to :group end We will now load a User and change both its group and...
You know that you can collect an array as groups using in_groups or in_groups_of. Maybe you want...
I've recently encountered a weird problem with specs making lots of SOLR queries using the acts_as_solr plugin...
Sometimes you need a file of some size (possibly for testing purposes). On Linux, you can use dd to create...
You don't need a Rails application to use Sass. Even when you're working on a static site you...
Given those modules: module A def foo; end def bar; end end module B end When you want to call...
Webmocks hash_including is similar to RSpec::Mocks::ArgumentMatchers#hash_including. Be aware that hash_including (webmock v3.0.1) doesn't...
Example task: Multiply the table holidays between several stages. Open two terminals: shell-for stage_1 shell-for stage_2...
...to re-send the request you could use the following snippet: def remote_request begin response = RestClient.get my_request_url rescue RestClient::ResourceNotFound => error @retries ||= 0 if @retries < @max_retries...
...retries (termination condition) was reached. With the retry statement you can re-execute the begin block that has been rescued from. Be aware that you could run into an infinite...
Cucumber has an output format that prints step definitions only. You can use this to find unused ones: Temporarily add...
You can seriously speed up deployments with Capistrano when using a local git repository on the server you are deploying...
Capybara does not play nice with sites that have some actions protected by SSL, some not. A popular way to...