Skip to content

Instantly share code, notes, and snippets.

@afian
afian / gist:8ec4dd66e097f2f37a8b
Last active August 29, 2015 14:13
Keeping footer pinned to bottom of page
@afian
afian / gist:bb040613e171f91435bc
Created January 16, 2015 11:46
Check if user signed in using devise
<% if user_signed_in? %>
@afian
afian / gist:d77353190186d4dc81b9
Created January 16, 2015 15:22
Using thin web server on Heroku
http://mattmazur.com/2012/01/18/how-to-switch-your-cedar-heroku-app-from-webrick-to-thin/
Add gem 'thin' to your Gemfile:
Bundle install
Add a Procfile to your root directory to instruct Heroku to use Thin instead of Webrick:
@afian
afian / gist:c310c05be7d6ccc90724
Last active August 29, 2015 14:13
Heroku useful addons

Sendgrid

$ heroku addons:add sendgrid:starter
$ heroku config:get SENDGRID_USERNAME

In config/environment.rb

ActionMailer::Base.smtp_settings = {
 :address        => 'smtp.sendgrid.net',
 :port =&gt; '587',
@afian
afian / gist:771f06d3422964548f3a
Created January 18, 2015 12:19
Navbar active state
<li class="<%= controller_name == 'pages' && action_name == 'about' ? 'active' : '' %>">
            <%= link_to("About", about_path) %>
          </li>
@afian
afian / gist:c819600d367c3332d003
Last active August 29, 2015 14:13
Devise installation and setup

Gemfile and bundle install

gem 'devise'

Install devise

$ rails generate devise:install

app/views/layouts/application.html.erb

$ rails generate scaffold pins description:string

followed by

$ rake db:migrate
@afian
afian / gist:76e53a54799d58877f58
Created January 19, 2015 04:22
Leading zeros in ruby
"file_" + i.to_s.rjust(n, "0")
@afian
afian / gist:64eefe9abf1decd11976
Created January 19, 2015 04:34
Authuenticating users in devise

In your controller

before_filter :authenticate_user!, :only => [:display]
  <%= link_to "<span class='fa fa-plus'></span> New Waybill</button>".html_safe, new_waybill_path, :class => "btn-u btn-red", :style => "float: right" %>