Comments (9)
@cellis Thanks!!!.
I think we should use Spree.user_class across this extension to work with custom user models.
@praveendhawan Can you look into this ?
from spree-account-recurring.
Same problem.
from spree-account-recurring.
@abrambailey, @cellis Could you please specify the steps to reproduce this problem.
from spree-account-recurring.
@abrambailey, @praveendhawan this is probably happening because I'm not using Spree::User
but instead using custom authentication, which user_decorator.rb
is unable to see, and therefore has_many :subscriptions
doesn't get added. I tried adding has_many :subscriptions, class_name: "Spree::Subscriptions"
but that doesn't work either.
from spree-account-recurring.
@cellis Can you try adding has_many :subscriptions, class_name: 'Spree::Subscription'
in your user model ?
from spree-account-recurring.
@priyank-gupta I've already tried that.
from spree-account-recurring.
@cellis Yeah, but the code you pasted above has s
in Spree::Subscription
. Not sure if its a typo you did here or in code.
from spree-account-recurring.
@priyank-gupta yeah I typed that out manually. I get the same problem.
from spree-account-recurring.
Alright, I've figured it out, for anyone coming after and seeing this bug:
If you use custom authentication, you'll need to create your own user decorator.
#spree-app/app/models/user_decorator.rb
#note, not using Spree::User
User.class_eval do
has_many :subscriptions, class_name: "Spree::Subscription", foreign_key: "user_id"
def find_or_create_stripe_customer(token=nil)
return api_customer if stripe_customer_id?
customer = if token
Stripe::Customer.create(description: email, email: email, card: token)
else
Stripe::Customer.create(description: email, email: email)
end
update_column(:stripe_customer_id, customer.id)
customer
end
def api_customer
Stripe::Customer.retrieve(stripe_customer_id)
end
end
After adding this file, I see
Running via Spring preloader in process 17727
Loading development environment (Rails 4.2.2)
oirb(main):001:0> User.first.subscriptions
User Load (4.8ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
Spree::Subscription Load (0.3ms) SELECT "spree_subscriptions".* FROM "spree_subscriptions" WHERE "spree_subscriptions"."user_id" = $1 [["user_id", 1]]
=> #<ActiveRecord::Associations::CollectionProxy []>
irb(main):002:0>
from spree-account-recurring.
Related Issues (11)
- Setting Up Provider HOT 7
- back from stripe
- Change the subscription or skip a month
- Renewal date
- Update credit card information
- How to eliminate uninitialized constant Spree::User (NameError)
- Unsubscribe error HOT 3
- Recurring plans should be an option for regular Spree products HOT 2
- Param is missing or the value is empty: subscription HOT 2
- undefined method `preference' for Spree::Recurring(Table doesn't exist) HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spree-account-recurring.