Rails 4.2 : SSL (https) in localhost

This worked for me (Rails 4.2)

include gem in your Gemfile

gem 'thin'
$ bundle install
$ thin start --ssl
>> Using rack adapter
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

Mimic Production/Staging

Mimicking your production/staging environment in your local machine may drag you into a series of problems. Your assets might not load properly. This is because in your in your production.rb / staging.rb you can see a line

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

Since you might not have passed `RAILS_SERVE_STATIC_FILES` environment variable via terminal, Rails refuses to server static assets. To make it happen you can either pass it via terminal or change the value to `true`

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s