title: Rails Routing - :action => 'new' returns error "No route matches {:action=>"show"... in the same controller
body: <p>I am writing the code for a model called "ExternalDatabase".</p>
  
  <p>The model file has no code in it outside of the class declaration. I have added view pages for index, new, show, and _form .html.erb. </p>
  
  <p>config/routes.rb contains the line <code>resources :external_databases</code>. The model contains no nested resources at this time. There are other models declared within this application, though none of them interact with this model at the moment and they are all tested and are functional and closed prior to declaring <code>resources :external_databases</code>. </p>
  
  <p>I have a link from within the index view to <code>new_external_database_path</code>, which behaves exactly like <code>{:action =&gt; "new", :controller =&gt; "external_database"}</code> if I am following correctly. </p>
  
  <p>This should theoretically load application/external_databases/new which will render <code>_form.html.erb</code>. The first line of <code>_form</code> is <code>&lt;%= form_for(@external_database) do |f| %&gt;</code></p>
  
  <p>The problem as stated in the post title occurs when using the link to /new. The url application/external_databases/new has the following error:</p>
  
  <p><code>No route matches {:action=&gt;"show", :controller=&gt;"external_databases"}</code></p>
  
  <p>When I created a data member using <code>rails console</code>, it was displayed properly by index and show. The same <code>_form</code> file is used by the <code>edit</code> method, and successfully edits the console-created data member. Destroy also functions. </p>
  
  <p>...So why isn't it recognizing the new method? </p>
  
  <p>My controller code for this model:</p>
  
  <pre><code>    class ExternalDatabasesController &lt; ApplicationController
  
       def index 
        @external_databases = ExternalDatabase.all
  
        respond_to do |format|  
         format.html # index.html.erb
         format.json { render :json =&gt; @external_databases }
        end
       end
  
       # POST /external_databases
       # POST /external_databases.json
  
       def new 
        @external_database = ExternalDatabase.new
  
        respond_to do |format|
         format.html # new.html.erb
         format.json { render :json =&gt; @external_database }
        end
       end
  
       def show
        @external_database = ExternalDatabase.find(params[:id])
  
        respond_to do |format| 
         format.html # show.html.erb
         format.json {render :json =&gt; @external_database }
        end
       end
  
       def create
        @external_database = ExternalDatabase.new(params[:external_database])
  
        respond_to do |format|
         if @external_database.save
          format.html {redirect_to @external_database, :notice =&gt; "New External Database         Profile was created successfully!"}
          format.json {render :json =&gt; @external_database, :status =&gt; :created, :location =&gt; @external_database}
         else
          format.html {render :action =&gt; "new"}
          format.json { render :json =&gt; @external_database.errors, :status =&gt;         :unprocessable_entity }
         end
        end
       end
  
  
       #GET /external_databases/1/edit
       def edit
        @external_database = ExternalDatabase.find(params[:id])
       end
  
       # PUT /external_databases/1
       # PUT /external_databases/1.json
       def update 
        @external_database = ExternalDatabase.find(params[:id])
  
        respond_to do |format|
         if @external_database.update_attributes(params[:external_database])
          format.html {redirect_to @external_database, :notice =&gt; "External Database         Profile was updated successfully!" }
          format.json {head :ok}
         else 
          format.html { redner :action =&gt; "edit" }
          format.json {render :json =&gt; @external_database.errors, :status =&gt;         :unprocessable_entity }
         end
        end
       end
  
  
       # DELETE /external_databases/1
       # DELETE /external_databases/1.json
       def destroy
        @external_database = ExternalDatabase.find(params[:id])
        @external_database.destroy
  
        respond_to do |format| 
         format.html { redirect_to external_databases_rul }
         format.json { head :ok }
        end
       end
  
      end
  </code></pre>
  
  <p>Update: Added routes.rb and Views code</p>
  
  <p>My routes.rb file:</p>
  
  <pre><code>    App::Application.routes.draw do
  
        resources :type_as do 
           resources :type_bs
           end
  
        resources :type_bs do 
          resources :type_as
          resources :type_cs
          end
  
        resources :type_cs do
         resources :type_bs
         end
  
        resources :external_databases
  
        root :to =&gt; "home#index"
  
      end
  </code></pre>
  
  <p><em>Views:</em></p>
  
  <p>external_databases_form</p>
  
  <pre><code>    &lt;%= form_for(@external_database) do |f| %&gt;
  
       &lt;div class="field"&gt;
        &lt;%= f.label :name %&gt;&lt;br/&gt;
        &lt;%= f.text_field :name %&gt;&lt;br/&gt;
       &lt;/div&gt;
       &lt;div class="field"&gt;
        &lt;%= f.label :description %&gt;&lt;br/&gt;
        &lt;%= f.text_field :description %&gt;&lt;br/&gt;
       &lt;/div&gt;
       &lt;div class="field"&gt;
        &lt;%= f.label :url %&gt;&lt;br/&gt;
        &lt;%= f.text_field :url %&gt;&lt;br/&gt;
       &lt;/div&gt;
       &lt;div class="actions"&gt;
         &lt;%= f.submit %&gt;
       &lt;/div&gt;
      &lt;% end %&gt;
  </code></pre>
  
  <p>index.html.erb</p>
  
  <pre><code>    &lt;p id="notice"&gt;&lt;%= notice %&gt;&lt;/p&gt;
      &lt;h1&gt;External Databases&lt;/h1&gt;
  
      &lt;table border="1"&gt;
       &lt;tr&gt;
        &lt;th&gt;Database Name&lt;/th&gt;
       &lt;/tr&gt;
       &lt;% @external_databases.each do |exdb| %&gt;
        &lt;tr&gt;
         &lt;td&gt;&lt;%= exdb.name %&gt;&lt;/td&gt;
         &lt;td&gt;&lt;%= truncate(exdb.description) %&gt;&lt;/td&gt;
         &lt;td&gt;&lt;%= link_to 'Show', exdb %&gt;&lt;/td&gt;
         &lt;!-- link_to.... :target =&gt; "_blank" will open the url in a new window --&gt;
         &lt;td&gt;&lt;%= link_to 'Visit', exdb.url, :target =&gt; "_blank" %&gt;&lt;/td&gt;  
         &lt;td&gt;&lt;%= link_to 'Edit', edit_external_database_path(exdb)%&gt;&lt;/td&gt;
         &lt;td&gt;&lt;%= link_to 'Destroy', exdb, :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/td&gt;
        &lt;/tr&gt;
       &lt;% end %&gt;
      &lt;/table&gt;
  
      &lt;br/&gt;
      &lt;%= link_to 'New External Database Profile', { :action =&gt; "new", :controller =&gt; "external_databases" }%&gt; | 
      &lt;%= link_to 'Home', root_path %&gt;
  </code></pre>
  
  <p>new.html.erb</p>
  
  <pre><code>    &lt;h1&gt;Creating a new External Database Profile&lt;/h1&gt;
  
      &lt;%= render 'form' %&gt;
  
      &lt;%= link_to 'Back', external_database_path %&gt;
  </code></pre>
  
  <p>show.html.erb</p>
  
  <pre><code>    &lt;p id="notice"&gt;&lt;%= notice %&gt;&lt;/p&gt;
  
      &lt;table cellspacing="3" cellpadding="5" border="1"&gt;
       &lt;tr&gt; 
        &lt;th&gt;&lt;b&gt;External Database Name&lt;/b&gt;&lt;/th&gt;
        &lt;th&gt;&lt;b&gt;Database ID&lt;/b&gt;&lt;/th&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
        &lt;td&gt;&lt;%= @external_database.name %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= @external_database.id %&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr colspan="2"&gt;
        &lt;th&gt;&lt;b&gt;URL&lt;/b&gt;&lt;/th&gt;
       &lt;/tr&gt;
       &lt;tr colspan="2"&gt;
        &lt;td&gt;&lt;%= @external_database.url %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= link_to 'Visit External Database', @external_database.url %&gt;&lt;/td&gt;
       &lt;/tr&gt;
      &lt;/table&gt;
  
  
  
      &lt;p&gt;
       &lt;h3&gt;Description&lt;/h3&gt;
       &lt;!% @external_database.description.split.scan(/.{,60}/).each do |line| %&gt;
        &lt;!%= line %&gt;&lt;br/&gt;
       &lt;!% end %&gt;
      &lt;/p&gt;
  
      &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
      &lt;%= link_to 'Back to External Database Index', external_databases_path %&gt; |
      &lt;%= link_to 'Edit', edit_external_database_path(@external_database) %&gt; | 
      &lt;%= link_to 'Destroy', :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;
  </code></pre>