sql - Rake task firing off mailer not returning correct results -
when apartment's unit number more 10 characters long , apartment's status available should trigger mailer. mailer fires off fine, returns listings instead of ones need. appreciated.
too_long.rake
namespace :listings desc 'notifies agent when unit long' task notify_agent_unit: :environment listing.all.each |listing| if listing.where("length(apartment) > 10") && listing.where(status: 'available') toolongmailer.unit_too_long(listing, listing.listing_agent).deliver_now end end end end
i couldn't work added scope in model works perfectly.
scope :unit_length_available, -> { where("length(apartment) > 10 , (status ilike '%available%')") }
Comments
Post a Comment