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 Contact < ActiveRecord::Base
with_options :dependent => :destroy do |parent|
parent.has_many :phones
parent.has_many :emails
parent.has_many :addresses
parent.has_one :photo
parent.has_one :user
end
require 'spec_helper'
include ActionView::Helpers
describe Content do
def rendered_contents
ContentRenderer.new(nil, {:contents => @contents, :skip_ids => true}).render_contents
end
class Vcard < ActiveRecord::Base
def import
@card = Vpim::Vcard.decode(self.data).first
get_data
find_contact
if @contact
def import
parse_card
if found_contact
update_contact
else
create_contact
end
class ResultList < ActiveRecord::Base
belongs_to :table
belongs_to :newsletter
has_many :contact_results, :dependent => :destroy
has_many :contacts, :through => :contact_results
def add_or_remove(length, remove)
remove ? (-1 * length) : length
end
require 'spec_helper'
include ActionView::Helpers
describe Content do
def rendered_contents
ContentRenderer.new(nil, {:contents => @contents, :skip_ids => true}).render_contents
end
require 'spec_helper'
describe ResultList do
before(:all) do
ResultList.all.map(&:destroy)
Contact.all.map(&:destroy)
@result_list = ResultList.create!
5.times do
class PdfFile < ActiveRecord::Base
belongs_to :result_list
has_attached_file :attachment, :path => "pdf/:id/:basename.:extension"
before_post_process :set_file_name
def generate_labels(params)
unless job_finish.nil?
accepts_nested_attributes_for :photo
def image_file=(new_image_file)
# "image/jpeg; charset=binary" --> jpeg
server_format = File.mime_type?(new_image_file).match(/^.*\/([^\;]*)/).captures.first.upcase
set_photo(server_format, :image_file => new_image_file)
end
def image_file_url=(new_image_file_url)
<%- content_tag :li, :id => "dropdown_#{dropdown.id}" do %>
<%= dropdown.name %>
<%- unless dropdown.filtered_webpages.length.zero? -%>
<ul class="sortable">
<%= hidden_field_tag "webpages[dropdown_#{dropdown.id}]", :id => nil %>