Skip to content

Instantly share code, notes, and snippets.

View sergii's full-sized avatar

Serhii Ponomarov sergii

View GitHub Profile
@sergii
sergii / Gemfile
Created March 4, 2014 12:03 — forked from Mikke/Gemfile
gem 'nokogiri'
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `connect'
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `block in connect'
/home/zzak/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
/home/zzak/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `connect'
/home/zzak/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
/home/zzak/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:750:in `start'
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent.rb:405:in `connection_for'
/home/zzak/.rvm/gems/ruby-1.9.

Some Rails Best Practices which are really best practices to me

Keep in mind

  1. Single Responsibity Principle (SRP).
  2. Skinny Controller, Fat Model.

Tips

  1. Start a new projet

Steps in creating a basic rails app

  1. Define your model(s)
  • What tables should exist in the database?
  • What fields should each table have?
  1. Define your associations
  • What are the relationships between your tables?
  1. Generate models
  2. Create your controllers

Deploying to Heroku

This guide is for a first-time Rails developer to deploy their app to Heroku, a popular web-hosting service with strong Rails support. This guide assumes you already have a Heroku account and have installed the Heroku Toolbelt.

Create Your App and Setup Heroku with Git

  1. Make sure you've setup an SSH key for Heroku. Follow this simple guide to create an SSH key and send it to Heroku if needed: Heroku: Managing Your SSH Keys
  2. Navigate into the folder for your Rails app.

Example Application Layout File

This is an example or boilerplate layout file. Your layout file is the frame rendered around every view in your app (via the <%= yield %> erb tag at the bottom). Every Rails app has a layout file at app/views/layouts/application.html.erb.

What's Included?

This layout file includes:

These steps are for Mavericks. Mileage will vary for older versions of Mac OS X but the broad strokes still apply. Google is your friend if you hit a snag. Comments welcome.

Installing Ruby & Rails on Mac OSX Mavericks

Install homebrew.

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@sergii
sergii / helper.rb
Last active August 29, 2015 14:08 — forked from gouthamvel/helper.rb
require 'active_support/core_ext/hash/keys'
class Hash
def recursively_symbolize_keys!
self.symbolize_keys!
self.values.each do |v|
if v.is_a? Hash
v.recursively_symbolize_keys!
elsif v.is_a? Array
v.recursively_symbolize_keys!
@sergii
sergii / hooks.rb
Last active August 29, 2015 14:10 — forked from enajski/hooks.rb
require 'pry'
After( '@developing' ) do |scenario|
binding.pry if scenario.failed?
end