Skip to content

Instantly share code, notes, and snippets.

def show
@photo = Photo.find(params[:id])
@user = @photo.user
@album = @photo.album
@is_current_user = @user.eql?(current_user)
@comment = Comment.new(params[:comment])
@previous = @photo.previous_photo
@next = @photo.next_photo
@related = Photo.find_related_to(@photo)
def begin_phone_transaction(vendor_user, client_user)
t = new
t.description = 'Phone Transaction'
t.state = 'progressing'
t.sender_user_transactions.build :user => client_user, :amount => Money.new(0, 'USD')
t.receiver_user_transactions.build :user => vendor_user, :amount => Money.new(0, 'USD')
t.receiver_user_transactions.build :user => SpecialUser.vipwithme_billing, :amount => Money.new(0, 'USD')
t.save!
t
[Mar 30 14:09:56] NOTICE[32079] chan_sip.c: Peer 'teliax' is now UNREACHABLE! Last qualify: 25
[Apr 1 08:20:07] NOTICE[32079] chan_sip.c: Peer 'teliax' is now UNREACHABLE! Last qualify: 24
[Apr 1 23:52:33] NOTICE[27637] chan_sip.c: Peer 'teliax' is now UNREACHABLE! Last qualify: 24
[Apr 4 14:09:16] NOTICE[27637] chan_sip.c: Peer 'teliax' is now UNREACHABLE! Last qualify: 25
def begin_phone_transaction(vendor_user, client_user, call_log)
vendor_tier1_user = vendor_user.parent
vendor_tier2_user = vendor_user.parent.parent if vendor_tier1
client_tier1_user = client_user.parent
client_tier2_user = client_user.parent.parent if client_tier1
t = new
t.description = 'Phone Transaction'
t.transaction_object = call_log
t.transaction_type = 'phone'
class CallLog < ActiveRecord::Base
has_one :transaction, :as => :transaction_object
composed_of :rate, :class_name => "Money", :mapping => [%w(rate_cents cents), %w(currency currency) ]
def update_call_time(session)
if session.in_conference?
time = Time.now - last_billed_time
self.last_billed_time = Time.now
self.billable_time = billable_time + time
save!
def update_phone_transaction
# Update from the transaction object
@vendor = receiver_user_transactions.first.user
@client = sender_user_transactions.first.user
# Amount client spends in cents
client_amount = (transaction_object.rate_cents * transaction_object.billable_time * -1 / 60).to_i
# Amount vendor receives
class ApplicationController < ActionController::Base
rescue_from ActionController::InvalidAuthenticityToken, :with => :bad_token
def bad_token
flash[:notice] = "Your session has expired."
respond_to do |accepts|
accepts.html do
store_location
redirect_to(:controller => '/sessions', :action => 'new') and return false
end
require 'activerecord'
module LoadRails
def load_rails
environment_file = File.expand_path(CONFIG["rails_root"] + "/config/environment.rb")
raise "There is no config/environment.rb file!" unless File.exists?(environment_file)
ENV['RAILS_ENV'] = CONFIG["rails_environment"] || 'development'
require environment_file
end
end
def verify
@phone_number = current_user.phone_numbers.find(params[:id])
if @phone_number
begin
adhearsion = DRbObject.new_with_uri "druby://vipwithme.com:9050"
rescue
connection_error = true
end
Event.addBehavior({
'div#feedback.pagination a' : Remote.Link
})