Skip to content

Instantly share code, notes, and snippets.

View tagrudev's full-sized avatar

Todor Grudev tagrudev

View GitHub Profile

adduser deploy
ssh-copy-id -i ~/.ssh/deploy.pub [email protected]

Install rbenv

aptitude install git

http://redcloth.org/

Setup Ubuntu Server

All commands need to be executed as root

sudo su

Server data architecture

class Log < ActiveRecord::Base
self.table_name = "versions"
has_one :previous_log, :class_name => "Log",
:order => "created_at DESC",
:conditions => proc{ "item_type = #{self.item_type}" }
end
=> NoMethodError: undefined method `item_type' for #<Class:0x7f9f5200c5f0>
<%= form_for(@project) do |f| %>
<% if f.errors.any? %>
<div id='error_explanation'>
<h2><%= pluralize(f.errors.count, 'error') %>
prohibited this foo from being saved:</h2>
<ul>
<% f.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
class PerspectivesController < ApplicationController
# GET /perspectives
# GET /perspectives.json
def index
@perspectives = Perspective.all
unless params['perspective']
@perspective = @perspectives.where(default: true).first || Perspective.new
else
@perspective = Perspective.new
end
@tagrudev
tagrudev / Gemfile
Last active December 14, 2015 09:09 — forked from anonymous/Gemfile
source 'http://rubygems.org'
# source 'http://localhost:9292'
gemspec
group :test do
gem "simplecov", :require => false
gem "shoulda-matchers"
gem "shoulda-context"
gem "capybara-screenshot"
@tagrudev
tagrudev / gist:4351631
Last active December 10, 2015 00:29 — forked from anonymous/gist:4351607
def create_report
if @inspection.type == 'RoutineInspection'
puts "---CR> CREATING ROUTINE INSPECTION REPORT"
pdf = routine_inspection_generic
else
puts "---CR> CREATING INGOING INSPECTION REPORT"
thread = Thread.new do
pdf = ingoing_inspection_nsw
end.join
end
def get_model_name(item)
item.class.to_s == Car.to_s ? item.content.class.to_s : item.class.to_s
end
module ApplicationHelper
def cp(*paths)
paths.each do |path|
#do something
end
end
end