Skip to content

Instantly share code, notes, and snippets.

NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.vat_rate):
/app/models/line_item.rb:49:in `set_vat'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `send'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `evaluate_method'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:166:in `call'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:93:in `run'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in `each'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in `send'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in `run'
namespace :synchronize do
desc "Synchronizing EFP and Edflats databases"
task(:synchronize => :environment) do
props = Property.find(:all)
@bookings = Array.new
if props.length > 0
props.each do |prop|
enquiries = Enquiry.find(:all, :conditions=>["property_id=? AND status='BOOKING_CONFIRMED' AND ISNULL(synced_at)", prop.id])
enquiries.each do |enq|
@bookings.push(enq.booking)
Mailer.deliver_booking_accepted(@booking.enquiry, urls(@booking.enquiry))
Mailer.deliver_landlord_booking_accepted(@booking.enquiry, urls(@booking.enquiry))
unless @booking.enquiry.property.web_property?
Mailer.deliver_booking_accepted_managed(@booking.enquiry, urls(@booking.enquiry))
end
#temporary deposit helper
def damage_deposit(ref)
Property.establish_connection(:efp)
@Eprop = Property.find(:first, :conditions=>["Prop=?", ref.slice(0,3)])
if [email protected]?
@Eprop.Prop_DD.to_i
else
100
end
end
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def sheet(*args, &block)
code = <<-EOF
<table border="0" cellspacing="0" cellpadding="0" width="#{args[0]}">
<tr>
<td height="11" width="6"><img src="/images/shadow_tl.png" width="6" height="11" border="0" /></td>
<td rowspan="2" style="background-color: #fff; padding: 2px;">
# This is a bugfix, probably broken it.
#while !xmldoc.find(path).empty? do
xmldoc.find(path).each do |e|
convert(e)
end
path << "/*"
#end
xmldoc.find("/*").each do |e|
begin
html_string << e.to_s
rescue
# do nothing
end
end
begin
require 'rubygems'
require 'hirb'
Hirb.enable
rescue LoadError => err
warn "Couldn't load File: #{err}"
end
def encode_flv_flash
Merb.logger.info "Encoding with encode_flv_flash"
transcoder = RVideo::Transcoder.new
recipe = "ffmpeg -i $input_file$ -ar 22050 -ab $audio_bitrate$k -f flv -b $video_bitrate_in_bits$ -r 24 $resolution_and_padding$ -y $output_file$"
recipe += "\nflvtool2 -U $output_file$"
transcoder.execute(recipe, self.recipe_options(self.parent_video.tmp_filepath, self.tmp_filepath))
end
def get_artist
Artist.find params[:artist_id]
end
def get_label
Label.find params[:label_id]
end
def parent_object