title: Simple Form: creating a new record from another controller
body: <p>I have a Home controller with an index view that acts like a search box that lets the user query a First Table or Second Table through a select box. After a user enters a search term, he will be redirected to the index page of the First or Second model with the search results for that model.</p>
  
  <p>A Search record must be created each time a query is submitted with the search type and search term. However, I don't know how to create a new Search object using simple_form from a different controller, which is the Home controller in this case.</p>
  
  <p>Home Controller</p>
  
  <pre><code>def index
    @find = Find.new
  </code></pre>
  
  <p>Home Index View</p>
  
  <pre><code>= simple_form_for @find, url: finds_path, method: :post do |f|
    = f.input :search_type, :collection =&gt; [['First', 'First'], ['Second', 'Second']]
    = f.input :search_term
    = f.button :submit
  </code></pre>
  
  <p>Finds Controller</p>
  
  <pre><code>def new
    @find = Find.new
  end
  
  def create
    @find = Find.new(find_params)
    if params[:search_type] == 'First'
      redirect_to first_path
    elsif params[:search_type] == 'Second'
      redirect_to second_path
    else
      redirect_to root_path
    end
  end
  
  private
  
  def find_params
    params.permit(:search_term, :search_type, :utf8, :authenticity_token, 
      :find, :commit, :locale)
    # the params seem to come from the Home controller so I added them just to see if they will go through :(
  end
  </code></pre>
  
  <p>It doesn't save. Instead it gives:</p>
  
  <pre><code>Started POST "/en/finds"
  Processing by FindsController#create as HTML
  Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"..", "find"=&gt;{"search_type"=&gt;"First", "search_term"=&gt;"Something"}, "commit"=&gt;"Create Find", "locale"=&gt;"en"}
  Unpermitted parameter: :find
  Redirected to http://localhost:3000/en
  </code></pre>