I'm having issues getting an instance variable to show up in my views. I'm setting it using a private method, and I'm using a before_filter to ensure that I can access it in the two places I need it. However, the instance variable is not showing up in the view, let alone having the needed action.
In my controller I have
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_filter :set_form, :only => [ :edit_password, :edit_email ]
...
def edit_password
@user = current_user
set_form('password')
end
def edit_email
@user = current_user
set_form('email')
end
...
private
def set_form(edit_type)
@form = edit_type
end
Here is the view file
<h1>Edit Your Account</h1>
<title><%= @form %></title>
<% if @form == 'email' %>
<%= render 'edit_email_form' %>
<% else %>
<%= render 'edit_password_form' %>
<% end %>
<%= link_to 'Back', user_path(@user) %>
I'm not sure what else I need to do to be able to use the instance variable in the view. I'm also wondering whether it's still possible to access the instance variable in the update statement after? Any help would be appreciated!