This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
include ActionView::Helpers | |
describe Content do | |
def rendered_contents | |
ContentRenderer.new(nil, {:contents => @contents, :skip_ids => true}).render_contents | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vcard < ActiveRecord::Base | |
def import | |
@card = Vpim::Vcard.decode(self.data).first | |
get_data | |
find_contact | |
if @contact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def import | |
parse_card | |
if found_contact | |
update_contact | |
else | |
create_contact | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
include ActionView::Helpers | |
describe Content do | |
def rendered_contents | |
ContentRenderer.new(nil, {:contents => @contents, :skip_ids => true}).render_contents | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe ResultList do | |
before(:all) do | |
ResultList.all.map(&:destroy) | |
Contact.all.map(&:destroy) | |
@result_list = ResultList.create! | |
5.times do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%- 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 %> | |