Ruby on Rails CORS setup for Heroku with Passenger 5.0.28

Ruby on Rails CORS setup for Heroku with Passenger 5.0.28

If you are using cloudfront with Heroku, chances are you will encounter some problems if you are using something like font-awesome. I won’t go into the details of how to setup cloudfont, but your heroku passenger should have the following. First, read the Passenger Documentation for Nginx configuration template.

These are the correct steps:

1. Copy the default ngnix config

Do this in the root directory of your Rails application.

cp $(passenger-config about resourcesdir)/templates/standalone/config.erb config/passenger_config.erb

Read More

Find a Ruby hash key by value

Find a Ruby hash key by value

Let’s take a very simple Ruby hash with some US state abbreviations to their names

us_states = {
  'AK' => 'Alaska',
  'AL' => 'Alabama',
  'AR' => 'Arkansas',
  'AZ' => 'Arizona',
  'CA' => 'California',
  'CO' => 'Colorado',
  'CT' => 'Connecticut'
}

Read More

Browserify-rails vs react-rails: Winner both

Browserify-rails vs  react-rails: Winner both

Recently, I have installed browserify-rails and react-rails together in the same Ruby on Rails project. This give the best of both worlds since I can still use the react_component helper provided by react-rails but use npm to manage my versions of different React.js components. However, if you install react-rails, make sure you do not run any of the generators.

Read More

Add Rubocop to every Rails project

The longer I have been in programming, the more I think that following best practices for coding style is an essential quality of a good programmer. When working on a team, I find many people want to debate about these things. While this can be fun, after a while it can become a time suck and a waste of energy. The best thing is to simply agree on a standard style guide and conform to it.

Read More