I am trying to simply create an instance variable that would be accessible in my `app/views/devise/registrations/edit.html.erb`, but it keeps coming back nil.
This is what I have done.
`app/views/users/registrations_controller.rb`:
class Users::RegistrationsController < Devise::RegistrationsController
def edit
if current_user_subscribed?
@plan = Stripe::Plan.retrieve(current_user.plan_name)
end
super
end
end
This is my `routes.rb`:
devise_for :users, controllers: {
invitations: 'invitations',
registrations: 'users/registrations'
},
path_names: { :sign_up => "register",
:sign_in => "login",
:sign_out => "logout",
:settings => "settings" }
This is my `app/views/devise/registrations/edit.html.erb`:
<% if current_user_subscribed? %>
<div class="col-md-12 subscribed-card">
<%= render partial: "subscriptions/card_brand", locals: { brand: current_user.card_brand, plan: @plan } %>
</div>
<% end %>
This is my `app/views/subscriptions/_card_brand.html.erb`
<div class="payment-card">
<div class="row">
<h2>Subscribed To: <%= plan.name %> for <%= formatted_price(plan.amount) %></h2>
</div>
</div>
But this is the error I am getting:
NoMethodError at /settings
undefined method `name' for nil:NilClass
What am I missing?