ruby on rails - Instance variable not showing in view forms -


i'm having issues getting instance variable show in views. i'm setting using private method, , i'm using before_filter ensure can access in 2 places need it. however, instance variable not showing in view, let alone having needed action.

in controller 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 view file

<h1>edit 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 else need able use instance variable in view. i'm wondering whether it's still possible access instance variable in update statement after? appreciated!

there's no value in setting set_form in before_filter, you're calling in methods.

you need explicitly render view file... don't see you're doing that. if form called (for example) edit_value.html.erb 2 edit_... methods need have

render :edit_value 

instance values not available in update statement. when update nothing available except information submitted in form or url, or saved in session hash, or persisted database.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -