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
# 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], |
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 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 |
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 Admin::PhotosController < Admin::TablesController | |
cache_sweeper :photo_sweeper, :only => [:create, :update, :destroy] | |
# standard methods for index, show, new, edit, update, destroy | |
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
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 | |
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
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
require 'spec_helper' | |
include ActionView::Helpers | |
describe Content do | |
def rendered_contents | |
ContentRenderer.new(nil, {:contents => @contents, :skip_ids => true}).render_contents | |
end | |