gem install rails
rails new my_app -T
=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') |
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: unicorn | |
# Required-Start: $local_fs $remote_fs mysql | |
# Required-Stop: $local_fs $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: unicorn initscript | |
# Description: Unicorn is an HTTP server for Rack application | |
### END INIT INFO |
# lib/active_admin_views_pages_base.rb | |
class ActiveAdmin::Views::Pages::Base < Arbre::HTML::Document | |
private | |
# Renders the content for the footer | |
def build_footer | |
div :id => "footer" do | |
para "Copyright © #{Date.today.year.to_s} #{link_to('Example.com', 'http://example.com')}. Powered by #{link_to('Active Admin', 'http://www.activeadmin.info')} #{ActiveAdmin::VERSION}".html_safe |
require 'carrierwave/processing/mini_magick' | |
class ImageUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
IMAGE_EXTENSIONS = %w(jpg jpeg gif png) | |
DOCUMENT_EXTENSIONS = %w(exe pdf doc docm xls) | |
def store_dir | |
"files/#{model.id}" |
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
check process redis | |
with pidfile /var/run/redis.pid | |
start program = "/etc/init.d/redis-server start" | |
stop program = "/etc/init.d/redis-server stop" | |
if failed host 127.0.0.1 port 6379 then restart | |
if 5 restarts within 5 cycles then timeout |
Get the Heroku db as detailed here: | |
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup | |
1. heroku pgbackups:capture | |
2. heroku pgbackups:url <backup_num> #=>backup_url | |
- get backup_num with cmd "heroku pgbackups" | |
3. curl -o latest.dump <backup_url> | |
Then locally do: | |
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump |
# Install libxml2 using Homebrew | |
# If you don't have Homebrew, follow the instructions at: | |
# https://github.com/mxcl/homebrew/wiki/Installation | |
# ------------------------------------------------------- | |
brew install libxml2 | |
# Install libxslt from source code | |
# If you don't have wget, follow the instructions at: | |
# http://www.mactricksandtips.com/2008/07/installing-wget-on-your-mac-for-terminal.html | |
# Or use Homebrew: |
# Support for Rspec / Capybara subdomain integration testing | |
# Make sure this file is required by spec_helper.rb | |
# | |
# Sample subdomain test: | |
# it "should test subdomain" do | |
# switch_to_subdomain("mysubdomain") | |
# visit root_path | |
# end | |
DEFAULT_HOST = "lvh.me" |