What is meant by ‘Assignment Branch Condition Size too high’ and how to fix it?

Assignment Branch Condition (ABC) size is a measurement of the size of a method. It is essentially determined by counting the number of Assignments, Branches, and Conditional statements. (more detail..) To reduce ABC score, you could move some of those assignments into before_action calls: before_action :fetch_current_category, only: [:show,:edit,:update] before_action :fetch_categories, only: [:show,:edit,:update] before_action :fetch_search_results, only: … Read more

Why is using the rails default_scope often recommend against?

Problem 1 Lets consider the basic example: class Post < ActiveRecord::Base default_scope { where(published: true) } end The motivation to make the default published: true, might be to make sure you have to be explict when wanting to show unpublished (private) posts. So far so good. 2.1.1 :001 > Post.all Post Load (0.2ms) SELECT “posts”.* … Read more

Can’t stop rails server

You can use other ports like the following: rails server -p 3001 Normally in your terminal you can try Ctrl + C to shutdown the server. The other way to kill the Ruby on Rails default server (which is WEBrick) is: kill -INT $(cat tmp/pids/server.pid) In your terminal to find out the PID of the … Read more

Continuous Integration for Ruby on Rails? [closed]

I just went through the options here and thought I’d roll them up as of late 2011. Integrity After a near-death experience that left the still-linked-to website with outdated information and downed the demo site, this project has a spark of life again. But the documentation hasn’t moved on, and lots and lots of the … Read more

No route matches [GET] /assets

In production mode, Rails will not be responsible for serving static assets. Therefore, you are getting this error. Thin won’t do it either, since it’s just a wrapper around Rails. This is controlled by this setting in config/environments/production.rb in your application: config.serve_static_files = false Or in Rails 5: # config/environments/production.rb config.public_file_server.enabled = true Or set … Read more