Question about data on plans
So I'm looking at how a plan is saved. It looks like the stripe id is saved with the features in the details, and that there is still a features column on the db. It doesn't look intentional, but I'm not sure what way you're going to change it to in the future.
Also, finding that the plans are sorted based on which ever one was updated last. Might be good to have a column to specify a sort order.
Also, finding that the plans are sorted based on which ever one was updated last. Might be good to have a column to specify a sort order.
Plan Load (2.4ms) SELECT "plans".* FROM "plans" WHERE "plans"."interval" = $1 [["interval", "month"]] => [#<Plan:0x00007fc15a38b350 id: 1, name: "Bells", amount: 0, interval: "month", details: {"features"=>["Yes, It's actually free", "These are just for an example"], "stripe_id"=>"free", "braintree_id"=>""}, created_at: Thu, 31 Oct 2019 03:20:13 UTC +00:00, updated_at: Thu, 31 Oct 2019 03:34:48 UTC +00:00, features: nil>, #<Plan:0x00007fc15a38b288 id: 3, name: "Whistles", amount: 0, interval: "month", details: {"features"=>["Example plan", "Also Free "], "stripe_id"=>"free2", "braintree_id"=>""}, created_at: Thu, 31 Oct 2019 03:32:12 UTC +00:00, updated_at: Thu, 31 Oct 2019 03:40:50 UTC +00:00, features: nil>, #<Plan:0x00007fc15a38b1c0 id: 4, name: "Bells & Whistles", amount: 0, interval: "month", details: {"features"=>["Why not have it all! ", "Subscription not actually required."], "stripe_id"=>"free3", "braintree_id"=>""}, created_at: Thu, 31 Oct 2019 03:33:06 UTC +00:00, updated_at: Thu, 31 Oct 2019 03:41:25 UTC +00:00, features: nil>]
Definitely good point on the sort order. Those should probably sort by amount.
That makes sense. Looks like it must go by amount first and then by updated_at as a 2ndary sort option based on my experience then.
Oh, another thing I found to be weird is that an admin by default can't access content because he doesn't have a subscription.
Also the admin edit subscription page for me was erroring out(500 I think). I haven't looked into it much yet.
Oh, another thing I found to be weird is that an admin by default can't access content because he doesn't have a subscription.
Also the admin edit subscription page for me was erroring out(500 I think). I haven't looked into it much yet.
I like that there would be a hidden free plan. The template doesn't have hidden plans by default. That would be nice too. being able to toggle hidden or not, and keep it available to the admin anyway. I like it. Good experience and more flexible than requiring them to be an admin in order to be free. 😀
Try this
1. Add hidden to the store_accessor
2. Add a scope:
3. Then add the scope to your pricing page.
Since it's an attribute this way, you can add it to the Administrate dashboard to toggle there as well. Seems easy enough to add to the template so I might just do that. 👍
1. Add hidden to the store_accessor
store_accessor :details, :features, :stripe_id, :braintree_id, :jumpstart_id, :hidden
2. Add a scope:
scope :without_hidden, -> { where.not("details @> ?", {hidden: true}.to_json) }
3. Then add the scope to your pricing page.
Since it's an attribute this way, you can add it to the Administrate dashboard to toggle there as well. Seems easy enough to add to the template so I might just do that. 👍
Success, thanks
Chris Oliver
!
This was already in Plan.rb and included in the
The solution you provided above worked, thanks again!
This was already in Plan.rb and included in the
monthly
and yearly
scopes, but setting the jumpstart_id
to :free
was not excluding it from the Pricing page:scope :without_free, -> { where.not(details: {jumpstart_id: :free}) }
The solution you provided above worked, thanks again!
The above worked when I set
Chris Oliver
On the administrate dashboard it is set as:
and appears as a checkbox on the form.
:hidden
to true
in the Rails console, however, when I add it to my administrate dashboard the field is being set to either "0" or "1", which is not being recognized by the scope. Not a huge deal since I'm fine setting it from the console, but wanted to mention it here On the administrate dashboard it is set as:
hidden: Field::Boolean
and appears as a checkbox on the form.
Notifications
You’re not receiving notifications from this thread.