Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8401723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:52:44+00:00 2026-06-09T21:52:44+00:00

I am writing the code for a model called ExternalDatabase. The model file has

  • 0

I am writing the code for a model called “ExternalDatabase”.

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.

config/routes.rb contains the line resources :external_databases. 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 resources :external_databases.

I have a link from within the index view to new_external_database_path, which behaves exactly like {:action => "new", :controller => "external_database"} if I am following correctly.

This should theoretically load application/external_databases/new which will render _form.html.erb. The first line of _form is <%= form_for(@external_database) do |f| %>

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:

No route matches {:action=>"show", :controller=>"external_databases"}

When I created a data member using rails console, it was displayed properly by index and show. The same _form file is used by the edit method, and successfully edits the console-created data member. Destroy also functions.

…So why isn’t it recognizing the new method?

My controller code for this model:

    class ExternalDatabasesController < ApplicationController

     def index 
      @external_databases = ExternalDatabase.all

      respond_to do |format|  
       format.html # index.html.erb
       format.json { render :json => @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 => @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 => @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 => "New External Database         Profile was created successfully!"}
        format.json {render :json => @external_database, :status => :created, :location => @external_database}
       else
        format.html {render :action => "new"}
        format.json { render :json => @external_database.errors, :status =>         :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 => "External Database         Profile was updated successfully!" }
        format.json {head :ok}
       else 
        format.html { redner :action => "edit" }
        format.json {render :json => @external_database.errors, :status =>         :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

Update: Added routes.rb and Views code

My routes.rb file:

    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 => "home#index"

    end

Views:

external_databases_form

    <%= form_for(@external_database) do |f| %>

     <div class="field">
      <%= f.label :name %><br/>
      <%= f.text_field :name %><br/>
     </div>
     <div class="field">
      <%= f.label :description %><br/>
      <%= f.text_field :description %><br/>
     </div>
     <div class="field">
      <%= f.label :url %><br/>
      <%= f.text_field :url %><br/>
     </div>
     <div class="actions">
       <%= f.submit %>
     </div>
    <% end %>

index.html.erb

    <p id="notice"><%= notice %></p>
    <h1>External Databases</h1>

    <table border="1">
     <tr>
      <th>Database Name</th>
     </tr>
     <% @external_databases.each do |exdb| %>
      <tr>
       <td><%= exdb.name %></td>
       <td><%= truncate(exdb.description) %></td>
       <td><%= link_to 'Show', exdb %></td>
       <!-- link_to.... :target => "_blank" will open the url in a new window -->
       <td><%= link_to 'Visit', exdb.url, :target => "_blank" %></td>  
       <td><%= link_to 'Edit', edit_external_database_path(exdb)%></td>
       <td><%= link_to 'Destroy', exdb, :confirm => 'Are you sure?', :method => :delete %></td>
      </tr>
     <% end %>
    </table>

    <br/>
    <%= link_to 'New External Database Profile', { :action => "new", :controller => "external_databases" }%> | 
    <%= link_to 'Home', root_path %>

new.html.erb

    <h1>Creating a new External Database Profile</h1>

    <%= render 'form' %>

    <%= link_to 'Back', external_database_path %>

show.html.erb

    <p id="notice"><%= notice %></p>

    <table cellspacing="3" cellpadding="5" border="1">
     <tr> 
      <th><b>External Database Name</b></th>
      <th><b>Database ID</b></th>
     </tr>
     <tr>
      <td><%= @external_database.name %></td>
      <td><%= @external_database.id %></td>
     </tr>
     <tr colspan="2">
      <th><b>URL</b></th>
     </tr>
     <tr colspan="2">
      <td><%= @external_database.url %></td>
      <td><%= link_to 'Visit External Database', @external_database.url %></td>
     </tr>
    </table>



    <p>
     <h3>Description</h3>
     <!% @external_database.description.split.scan(/.{,60}/).each do |line| %>
      <!%= line %><br/>
     <!% end %>
    </p>

    <br /><br /><br />
    <%= link_to 'Back to External Database Index', external_databases_path %> |
    <%= link_to 'Edit', edit_external_database_path(@external_database) %> | 
    <%= link_to 'Destroy', :confirm => 'Are you sure?', :method => :delete %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:52:45+00:00Added an answer on June 9, 2026 at 9:52 pm

    You have a typo in your new.html.erb file in your ‘back’ link. It should be:

    external_databases_path
    

    You can compare it with your own back link in show.html.erb above.

    Fixed: new.html.erb

    <h1>Creating a new External Database Profile</h1>
    
    <%= render 'form' %>
    
    <%= link_to 'Back', external_databases_path %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While writing code in a file that would comprise of PHP, HTML, CSS &
I am writing code to clone object but have no cue from Hobo documentation.
I'm writing code in PHP that requires including a config.php file depending on the
I have a very beginning C# question. Suppose I have a class called GameObject
I am a fan of Martin Fowler's (deprecated) model-view-presenter pattern. I am writing a
I'm writing a simple Rails model called Person that has_many :phone_numbers and I'm trying
Hallo, Here's some code which writes a data class to a file, then checks
I'm writing some code to automatically tag some articles. I have an array of
I have code which is updating a model's property then calling save! . A
When writing code, I often place debug messages in the code. The debug messages

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.