title: Having Trouble Using Session in Rails undefined local variable or method
body: <p>I have a devise registration controller here</p>
  
  <pre><code>class Students::RegistrationsController &lt; Devise::RegistrationsController
  
    def after_sign_up_path_for(resource)
      '/events/new'
    end 
  
    def after_inactive_sign_up_path(resource)
      '/events/new'
    end 
  
    def brand
      brand ||= Brand.find(params[:brand]) 
      session[:brand] = Brand.find(params[:brand]) #not working 
    end 
    helper_method :brand 
  end
  </code></pre>
  
  <p>after somebody sign up it will send them to events/new page </p>
  
  <p>Before someone goes to the sign up page, they will have to go through a brands page</p>
  
  <pre><code>=link_to t('slide2.apply_here'), new_student_registration_path(:brand =&gt; brand.id),class: "button-component", style: "font-size: 14px; padding: 10px 50px;"
  </code></pre>
  
  <p>please note that the brand id is getting passed through the link_to as a params to the registration controller. I have the brand method to capture the brand id, find the brand and use it on the view in the sign up page. </p>
  
  <p>I want to do the same thing for events/new hence storing the Brand in the session. </p>
  
  <p>I keep on getting undefined local variable or method brand. </p>
  
  <p>I have this in events new view</p>
  
  <pre><code>%h3=brand.name
  </code></pre>
  
  <p>I know session should be short, it should just be</p>
  
  <pre><code>session[:brand] = params[:brand]
  </code></pre>
  
  <p>but then I am getting my signup page undefined now, its messing up my helper method. </p>
  
  <p>updated</p>
  
  <p>I just dropped this in my events new view</p>
  
  <pre><code>.row
    .span4
      .accordion#picture_accordion.left
      =image_tag brand.image_url
      %h3=brand.name
  </code></pre>