Ruby on rails 无方法错误:未定义的方法'find#u each';对于用户:类
我编写了一个调度程序函数,自动检查用户的免费试用是否结束,然后自动将其升级为付费订阅。问题是,当我尝试从命令行运行任务时,出现以下错误: 无方法错误:用户:类的未定义方法“find_each”Ruby on rails 无方法错误:未定义的方法'find#u each';对于用户:类,ruby-on-rails,ruby,heroku,Ruby On Rails,Ruby,Heroku,我编写了一个调度程序函数,自动检查用户的免费试用是否结束,然后自动将其升级为付费订阅。问题是,当我尝试从命令行运行任务时,出现以下错误: 无方法错误:用户:类的未定义方法“find_each” 我的应用程序托管在heroku上,我正在尝试在那里运行作业。感谢您的帮助!谢谢 find\u每个方法都是ActiveRecord方法,这意味着用户类必须从ActiveRecord继承。如果您没有使用这种ORM,则不能使用find\u each 如果您确实提供了用户类代码库,则会容易得多 Cheersfin
我的应用程序托管在heroku上,我正在尝试在那里运行作业。感谢您的帮助!谢谢
find\u每个
方法都是ActiveRecord
方法,这意味着用户类必须从ActiveRecord继承。如果您没有使用这种ORM,则不能使用find\u each
如果您确实提供了用户
类代码库,则会容易得多
Cheers
find\u每个
方法都是ActiveRecord
方法,这意味着用户类必须从ActiveRecord继承。如果您没有使用这种ORM,则不能使用find\u each
如果您确实提供了用户
类代码库,则会容易得多
干杯
find\u每个
方法都是ActiveRecord
方法,因此您的用户类必须从ActiveRecord继承。您确定要使用此ORM吗?请提供用户类代码。find\u每个
方法都是ActiveRecord
方法,因此您的用户类必须从ActiveRecord继承。您确定要使用此ORM吗?请提供用户类代码。
task :process_trial_accounts => :environment do
puts "Processing Trial Users"
User.find_each do |user|
plan_id = MailFunnelsUser.get_user_plan(user.client_id)
if plan_id == -99
products = Infusionsoft.data_query('SubscriptionPlan', 100, 0, {}, [:Id, :PlanPrice])
product = products.select { |product| product['Id'] == 2 }[0]
unless product
end
price = product['PlanPrice']
cardId = 0
current_year = Date.today.strftime('%Y')
current_month = Date.today.strftime('%m')
creditCardId = Infusionsoft.data_query('CreditCard',
100,
0,
{'ContactId' => user.clientid, 'ExpirationYear' => '~>=~' + current_year, 'Status' => 3},
[:Id, :ContactId, :ExpirationMonth, :ExpirationYear]
).each do |creditCard|
if Integer(creditCard['ExpirationYear']) == Integer(current_year)
if Integer(creditCard['ExpirationMonth']) >= Integer(current_month)
cardId = creditCard['Id']
end
else
cardId = creditCard['Id']
end
end
if cardId != 0
subscription_id = Infusionsoft.invoice_add_recurring_order(user.clientid, true, 2, 4, cardId, 0, 0)
invoice_id = Infusionsoft.invoice_create_invoice_for_recurring(subscription_id)
upgrade_response = Infusionsoft.invoice_charge_invoice(invoice_id, "Automatic Upgrade to 1000 Subscriber Tier", cardId, 4, false)
if upgrade_response[:Successful]
# Tag for 1000 sub tier level plan
new_tier_level_tag = 106
# Tags to remove from user
trial_ended_tag = 145
failed_payment_tag = 120
# Remove Tags from user for failed payment and Trial ended
Infusionsoft.contact_remove_from_group(user.clientid, trial_ended_tag)
Infusionsoft.contact_remove_from_group(user.clientid, failed_payment_tag)
# Add tag to user for 1000 subscribers tier level
Infusionsoft.contact_add_to_group(user.clientid, new_tier_level_tag)
end
end
else
next
end
end
end