6 things missing from Rails

… That you will probably end up creating yourself …

When should you throw everything out and start over

After over 12 years of working with Ruby on Rails on multiple different codebases, I’ve some common themes. This is my list of patterns or types of objects you will see in Rails applications.

1. Query Objects.

ActiveRecord provides the scope macro which allows us to define queries related to that model. However, for larger, more complex queries that span multiple models, scopes can often lead to a patchwork of distributed logic. To address this, I prefer to build stand alone a Query object. I usually place this in a separate folder: `app/queries’. The following is an example of query object:

A simple base query object:

module Kenglish
  QueryResult = Struct.new(:data, :meta)

  class Query
    class << self
      def result(*args)
        new(*args).result
      end
    end

    attr_reader :params, :relation

    def initialize(params, relation)
      @params = params
      @relation = relation
    end

    def build_result(data, meta)
      QueryResult.new(data, meta)
    end
  end
end

Read More

6 Health Care Companies That You Probably Didn’t Know Use Ruby on Rails.

Rails is dead! Long live Ruby on Rails!

A recent discussion on the Ruby Rogues podcast reminded me that since I started doing Ruby on Rails in 2007, the platform really hasn’t lost any momentum. Companies continue to reach for this product to build custom web applications. With the right talent on a team, it can be a very productive endevoru

Here’s a few companies that I know use Ruby on Rails for some of their products if not their main product.

1. Doximity

A pioneer of mobile health apps to connect health care professionals and make them more productive, Doximity’s dynamic team delivers with Ruby on Rails alongside whatever other technology they need to get the job done. They promote growth among their developers and this is one of the key assets of good Ruby on Rails development team. Doximity

Read More

Ansible [DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the full variable syntax

Ansible [DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the full variable syntax

If you recently upgraded Ansible and you are getting an error like:

[DEPRECATION WARNING]: Using bare variables is deprecated. Update your
playbooks so that the environment value uses the full variable syntax
('{{rbenv_plugins}}').
This feature will be removed in a future release.
Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.

Read More

Nested Routes and Namespaced Controllers in Rails

Nested Routes and Namespaced Controllers in Rails

I see many project get nested routes wrong. Developers do not use Ruby modules to reflect the relationship between the parent and children nesting of controllers. Here is an example of the wrong way (IMHO). Let’s say we have a customer and the customer has_many orders and has_one profile. Some developers will represent it like this.

/customers path in the file app/controllers/customers_controller.rb

class CustomersController < ApplicationController
  def index
    ...
  end
end

Read More