Skip to content

Instantly share code, notes, and snippets.

View patrick99e99's full-sized avatar

Patrick Collins patrick99e99

  • collinator studios
  • Saratoga Springs, Utah
View GitHub Profile
class Webpage < ActiveRecord::Base
belongs_to :dropdown
has_many :contents, :order => "parent_id, layout_order"
end
class Content < ActiveRecord::Base
belongs_to :element
belongs_to :webpage
end
module WebpagesHelper
def display_html_content(contents, mode = nil)
completed_elements, dropzone_id_list, sortable_list, output = [], [], [], []
contents.map do |c|
unless completed_elements.include?(c.id)
result = get_nested_elements(c, contents, completed_elements, dropzone_id_list, sortable_list, mode)
require 'polaroid.rb'
def shipping_label
@from_address = Setting.find_by_name("shipping_from_address").address
@to_address = Address.find(params[:file_name].split("_").last)
prawnto :prawn => {
:page_layout => :landscape,
:page_size => [79.2, 252.0],
:left_margin => 0,
:right_margin => 0,
:top_margin => 0,
acts_as_fleximage do
image_directory "/media/master_images"
use_creation_date_based_directories true
# image_storage_format :jpg # the plugin is handling this now
require_image true
missing_image_message 'is required'
invalid_image_message 'was not a readable image'
# default_image_path 'public/images/image_not_available.png'
default_image nil
def file_path
# -- I changed this line from: --
# "#{directory_path}/#{id}.#{self.class.image_storage_format}"
"#{directory_path}/#{id}.#{self.server_format}"
end
def pre_save
if @uploaded_image
# perform preprocessing
perform_preprocess_operation
# controller action
def result_list
type = (params[:newsletter_id].to_i.zero? ? 'PdfList' : 'Newsletter').constantize
result_list = type.find(params[:result_list_id])
unless result_list.in_progress?
call_rake :result_list, :function => params[:submit_button],
:result_list_id => result_list.id,
:search => (params[:search].blank? ? nil : params[:search].strip),
:search_scope => params[:search_scope],
class Photo
belongs_to :photo_album
def set_cover(cover)
if cover
photo_album.cover = self
elsif photo_album.cover.nil?
# set album cover to first photo album if no cover has been set.
photo_album.cover = photo_album.photos.first
def set_cover(should_be_cover, photo)
if should_be_cover
cover = photo
elsif cover.nil?
# set album cover to first photo album if no cover has been set.
cover = photos.first
end
end
class Admin::PhotosController < Admin::TablesController
cache_sweeper :photo_sweeper, :only => [:create, :update, :destroy]
# standard methods for index, show, new, edit, update, destroy
end