Skip to content

Commit

Permalink
fix: verification of active subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
castrolem committed Oct 15, 2019
1 parent 6c1e492 commit 3f44ba0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class StaticPagesController < ApplicationController
def home
@current_user = current_user
@current_user_subscription = @current_user.active_subscription
@plans = Plan.all.order('amount asc')
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ def current_streak
end

def active_subscription
subscriptions.active
subscriptions.active unless subscriptions.active.blank?
end
end
2 changes: 1 addition & 1 deletion app/views/static_pages/home.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</h3>
<h4><%= plan.headline %></h4>
<%= plan.description %>
<% if @current_user&.active_subscription&.plan.id == plan.id %>
<% if @current_user_subscription&.plan&.id == plan.id %>
<p>Subscribed</p>
<% else %>
<p><%= link_to 'Subscribe', @current_user ? new_subscription_charge_path(plan_id: plan) : login_path %></p>
Expand Down

0 comments on commit 3f44ba0

Please sign in to comment.