Skip to content

Instantly share code, notes, and snippets.

View mdunbavan's full-sized avatar

Mark Dunbavan mdunbavan

View GitHub Profile
// The model for the gallery images allowing multi file uploads
<?php
class GalleryImage extends Eloquent {
// protected $guarded = array();
// public static $rules = array();
public function __construct(array $attributes = array()) {
<!-- Not the FULL view -->
<link rel="stylesheet" href="{{ url('css/sir-trevor-icons.css')}}" type="text/css">
<link rel="stylesheet" href="{{ url('css/sir-trevor.css')}}" type="text/css">
<!-- Using some Bootstrap here -->
<div class="container">
<div class="row" id="post-form-container">
<h3>Create A Post</h3>
<form method="post" action="form" id="post-form" role="form">
<div class="form-group">

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@mdunbavan
mdunbavan / gist:9598366
Created March 17, 2014 12:27
Capistrano setup
// Capfile
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.ketchup.all.min.js" type="text/javascript"></script>
</head>
<body>
<div id="email">
<span>Enter your email to sign up</span>
<form action="/subscribe.php" id="invite" method="POST">
# http://stackoverflow.com/a/8936202
#
# ActiveAdmin already includes the necessary jquery in active_admin/base,
# so just add this to javascripts/active_admin.js after //= require active_admin/base
#
#
# Serialize and Sort
#
# model_name - you guessed it, the name of the model we are calling sort on.
# This is the actual variable name, no need to change it.
@mdunbavan
mdunbavan / gist:67a7e2d9311721681563
Last active August 29, 2015 14:06
rails book show view
// Show view
<p id="notice"><%= notice %></p>
<p>
<strong>Title:</strong>
<%= @book.title %>
</p>
<p>
<strong>Synopsis:</strong>
@mdunbavan
mdunbavan / gist:0dd592b6a8878a664ab0
Created September 16, 2014 19:45
Rails controllers for gallery on books
class BooksController < ApplicationController
before_action :set_book, only: [:show, :edit, :update, :destroy]
before_filter :authenticate_user!, only: [:new, :edit, :update, :destroy]
def index
@books = Book.order('created_at DESC').all
end
def show
@book = Book.friendly.find(params[:id])
@mdunbavan
mdunbavan / log after book create
Last active August 29, 2015 14:06
Rails image uploading models and controllers
#controllers for the gallery and image
#images_controller.rb that creates the image
class ImagesController < ApplicationController
before_action :set_image, only: [:show, :edit, :update, :destroy]
def show
@image = Image.find(params[:id])
end