Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError (wrong number of arguments (given 0, expected 1)) #26

Open
cgcmart opened this issue Mar 30, 2018 · 4 comments
Open

ArgumentError (wrong number of arguments (given 0, expected 1)) #26

cgcmart opened this issue Mar 30, 2018 · 4 comments

Comments

@cgcmart
Copy link

cgcmart commented Mar 30, 2018

Rails server logged these warnings:

W, [2018-03-27T18:09:54.706656 #23348] WARN -- : Creating scope :loyalty_points_not_awarded. Overwriting existing method Spree::Order.loyalty_points_not_awarded.
W, [2018-03-27T18:09:54.706758 #23348] WARN -- : Creating scope :with_hours_since_payment. Overwriting existing method Spree::Order.with_hours_since_payment.
W, [2018-03-27T18:09:54.706808 #23348] WARN -- : Creating scope :with_uncredited_loyalty_points. Overwriting existing method Spree::Order.with_uncredited_loyalty_points.

I run:
bundle exec rake spree:loyalty_points:award
rake aborted!
ArgumentError: wrong number of arguments (given 0, expected 1)

with spree-loyalty-points/app/models/concerns/spree/order/loyalty_points.rb
Line 15:
create_credit_transaction(loyalty_points_earned)
Line 32:
uncredited_orders.each do |order|
Line 33:
order.award_loyalty_points
Line 40:
user.loyalty_points_credit_transactions.create(source: self, loyalty_points: points)

Traceback (most recent call last):
from app/models/spree/order_decorator.rb:11:in block (2 levels) in <top (required)>
ArgumentError (wrong number of arguments (given 0, expected 1))

Line 11: scope :with_hours_since_payment, ->(num) { where('spree_orders.paid_at < ? ', num.hours.ago) }
from app/models/spree/order_decorator.rb:13:in block (2 levels) in <top (required)>
ArgumentError (wrong number of arguments (given 0, expected 1))

Line 13: scope :with_uncredited_loyalty_points, ->(num) { with_hours_since_payment(num).loyalty_points_not_awarded }

Please confirm this gem does work, or should do something with spree-loyalty-points/app/models/concerns/spree/order/loyalty_points.rb and spree-loyalty-points/app/models/spree/order_decorator.rb

@harsh-ag
Copy link

Hi @99cm ,

I was trying to replicate your bug with latest(master) branch, although it seems to be working fine there. Can you please specify the versions of spree, rails and ruby you are using.

@cgcmart
Copy link
Author

cgcmart commented Mar 30, 2018

ruby 2.5.0
rails 5.1.5
spree 3.4.4

my rails app started 2 years ago with ruby 2.3.0, rails 4.2, spree 3.1, and installed spree-loyalty-points that I believe never working in production, mostly caused by rake cron job failure. there are 3 developers worked on issues, unfortunately, unsolved, because loyalty_points not awarded to user.

Readme:

Update Loyalty Points in the system

Loyalty Points will be awarded to the customer only after:

Admin captures the payment manually for his order
“Time” set in Loyalty Point configuration has elapsed after capturing the payment.

Add a Cron Job to run the following rake task to award Loyalty Points to customers who satisfy the above two conditions.

bundle exec rake spree:loyalty_points:award

irb output

irb(main):002:0> Spree::Order.with_hours_since_payment
Traceback (most recent call last):
2: from (irb):5
1: from app/models/spree/order_decorator.rb:11:in `block (2 levels) in <top (required)>'
ArgumentError (wrong number of arguments (given 0, expected 1))

irb(main):006:0> Spree::Order.with_uncredited_loyalty_points
Traceback (most recent call last):
2: from (irb):6
1: from app/models/spree/order_decorator.rb:13:in `block (2 levels) in <top (required)>'
ArgumentError (wrong number of arguments (given 0, expected 1))

Since loyalty_points not awarded, one developer wrote a configure code

config/schedule.rb
every 1.day, at: '5:05 am' do rake 'spree:loyalty_points:award' end

This effort did not work.

@harsh-ag
Copy link

Hi @99cm,
Currently, we are not supporting this extension(spree_loyalty_points) for the versions of Spree which have introduced Store Credits because this extension creates a new payment method for Loyalty Points which is no longer needed in them. And, we can simply use store credits to create such program.

@cgcmart
Copy link
Author

cgcmart commented Mar 30, 2018

Thank you for your time to answer my question and letting me know store credit similar to loyalty points except a method of refund. I knew spree with store credit, but I paid attention to loyalty_points. I'll learn how to use store credit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants