title: Rails Import CSV - No Route Matches
body: <p>I'm very new to Rails. I'm currently trying to import data from an csv file into my rails application. However, when I followed examples and guides online, I got the error: <b><em>No route matches {:action=>"import_csv", :controller=>"lists"}</em></b> I've already added it in my routes.rb though. Can anyone help me check what is wrong if my codes to cause to 'no route matches' error? Below are my files:</p>
  
  <h3>lists_controller.rb</h3>
  
  <pre><code>def import_csv
  
  require 'fastercsv' 
  
  respond_to do |format|
  @csv=params[:file].read
  @n=0
  @parsed_file = CSV.parse(csv)
  @parsed_file.each  do |row|
    @user_new = User.new
    @user_new.first_name = row[0]
    @user_new.last_name = row[1]
    @user_new.email = row[2]
    @user_new.address = row[3]
    @user_new.city = row[4]
    @user_new.state = row[5]
    @user_new.zip = row[6]
    @user_new.country = row[7]
    @user_new.notes = row[8]
    @user_new.birthday = row[9]
    @user_new.home_number = row[10]
    @user_new.mobile_number = row[11]
    @user_new.list_id = list_id
    @user_new.save
    @n=@n+1
    GC.start if n%50==0
      flash[:notice] = "CSV Imported Successfully, with  #{n} records"                                
  end
  
  format.html { redirect_to lists_url }
    format.json { head :no_content }
  end
    end
  </code></pre>
  
  <h3>app/views/lists/show.html.erb</h3>
  
  <pre><code>&lt;%= form_for(:list, :url =&gt; list_import_csv_path,  :html =&gt; {:multipart =&gt; true}) do |f| %&gt;
   &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;label for="dump_file"&gt;Select a CSV File :&lt;/label&gt;&lt;/td&gt;
          &lt;td &gt;&lt;%= file_field_tag :file %&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td colspan='2'&gt;&lt;%= submit_tag 'Submit' %&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <h3>routes.rb</h3>
  
  <pre><code>  resources :lists do
      get 'import_csv'
      #match '/import_csv/:id' =&gt; 'lists#import_csv', :as =&gt; :import_csv
    end
  </code></pre>
  
  <h3> rake routes </h3>
  
  <pre><code>    identities GET    /identities(.:format)                        identities#index
                    POST   /identities(.:format)                        identities#create
       new_identity GET    /identities/new(.:format)                    identities#new
      edit_identity GET    /identities/:id/edit(.:format)               identities#edit
           identity GET    /identities/:id(.:format)                    identities#show
                    PUT    /identities/:id(.:format)                    identities#update
                    DELETE /identities/:id(.:format)                    identities#destroy
  newsletter_cancel GET    /newsletters/:newsletter_id/cancel(.:format) newsletters#cancel
        newsletters GET    /newsletters(.:format)                       newsletters#index
                    POST   /newsletters(.:format)                       newsletters#create
     new_newsletter GET    /newsletters/new(.:format)                   newsletters#new
    edit_newsletter GET    /newsletters/:id/edit(.:format)              newsletters#edit
         newsletter GET    /newsletters/:id(.:format)                   newsletters#show
                    PUT    /newsletters/:id(.:format)                   newsletters#update
                    DELETE /newsletters/:id(.:format)                   newsletters#destroy
    list_import_csv GET    /lists/:list_id/import_csv(.:format)         lists#import_csv
              lists GET    /lists(.:format)                             lists#index
                    POST   /lists(.:format)                             lists#create
           new_list GET    /lists/new(.:format)                         lists#new
          edit_list GET    /lists/:id/edit(.:format)                    lists#edit
               list GET    /lists/:id(.:format)                         lists#show
                    PUT    /lists/:id(.:format)                         lists#update
                    DELETE /lists/:id(.:format)                         lists#destroy
              users GET    /users(.:format)                             users#index
                    POST   /users(.:format)                             users#create
           new_user GET    /users/new(.:format)                         users#new
          edit_user GET    /users/:id/edit(.:format)                    users#edit
               user GET    /users/:id(.:format)                         users#show
                    PUT    /users/:id(.:format)                         users#update
                    DELETE /users/:id(.:format)                         users#destroy
  </code></pre>