title: Rails 5 - Render New with Parameter
body: <p>I have checked old similar post but but I'm still having problems.</p>
  
  <p>When I create a new listing the URL looks as below:
  <a href="http://localhost:3000/listings/new?plan=1" rel="nofollow noreferrer">http://localhost:3000/listings/new?plan=1</a></p>
  
  <p>In the form_for I'm hiding some fields when plan=1</p>
  
  <pre><code>&lt;%= form_for(@listing) do |f| %&gt;
  &lt;%= render 'shared/error_messages', object: f.object %&gt;
  
    &lt;%= f.hidden_field :plan, :value =&gt; @plan %&gt;
  
    &lt;%= f.label :Title %&gt;
    &lt;%= f.text_field :title, class: 'form-control' %&gt;
  
    &lt;!-- don't show description for standard plan --&gt;
    &lt;% if @plan != 1.to_s %&gt;
      &lt;%= f.label :Description %&gt;
      &lt;%= f.text_area :description, :rows =&gt; 10,
        placeholder: "Describe your business...", class: 'form-control' %&gt;
    &lt;% end %&gt;   
  </code></pre>
  
  <p>In the ListingsController I set the plan in before action:</p>
  
  <pre><code>before_action :set_plan,        only: [:new, :create]
  
      def set_plan
        @plan = params[:plan]
      end 
  </code></pre>
  
  <p>so I can use it as hidden field on the form above.</p>
  
  <p>My problem starts when I save the form with errors.
  The new form URL changes to <a href="http://localhost:3000/listings" rel="nofollow noreferrer">http://localhost:3000/listings</a>.
  I can see the @plan=1 still on the form:</p>
  
  <pre><code>&lt;input value="1" type="hidden" name="listing[plan]" id="listing_plan" /&gt;
  </code></pre>
  
  <p>, but now the form is showing all fields (which should be hidden due to this condition &lt;% if @plan != 1.to_s %>)</p>
  
  <p>Actions in ListingsController:</p>
  
  <pre><code>  def new
      @listing = Listing.new
    end
  
    def create
      @listing = current_user.listings.build(listing_params) if logged_in?
      @plan = @listing.plan
  
      if @listing.save
        flash[:success] = "Listing created!"
        redirect_to @listing
      else
        render 'new'
      end
    end
  </code></pre>
  
  <p>I have tried something like that but no success:
  render :action => 'new', :plan => @listing.plan
  and few other things</p>
  
  <p>How can I hide those fields on error?</p>