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

  • Home
  • SEARCH
  • 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 6338453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:26:52+00:00 2026-05-24T19:26:52+00:00

How do I specify the Controller and Action in a form submission? I am

  • 0

How do I specify the Controller and Action in a form submission? I am trying to use a ‘Clients’ Controller to create an Account and an associated Person (‘Client’).

Here are the pertinent models. A Person belongs either to an Account directly (which I am calling a ‘Client’) or to a Location and Organization within an Account.

class Account < ActiveRecord::Base
    has_many :organizations
    has_many :persons, :as => :linkable

    accepts_nested_attributes_for :organizations
end

class Person < ActiveRecord::Base
    belongs_to :linkable, :polymorphic => true
end

And here is the form to create a ‘Client’ I am trying to make along with the rest of the code:

<%= form_for @account, :url => { :controller => "clients_controller", 
                                 :action => "create" } do |f| %>

<%= f.fields_for :persons do |builder| %>
    <%= builder.label :first_name %><br />
    <%= builder.text_field :first_name %><br />
    <%= builder.label :last_name %><br />
    <%= builder.text_field :last_name %><br />
    <%= builder.label :email1 %><br />
    <%= builder.text_field :email1 %><br />
    <%= builder.label :home_phone %><br />
    <%= builder.text_field :home_phone %><br />         
  <% end %>

  <%= f.submit "Add client" %>
<% end %>


class ClientsController < ApplicationController

  def new
      @account = Account.new
      @person = @account.persons.build
  end

  def create
      @account = Account.new(params[:account])
      if @account.save
          flash[:success] = "Client added successfully"
          render 'new'
      else
          render 'new'
      end
  end

end

And here are my routes:

ShopManager::Application.routes.draw do

resources :accounts
resources :organizations
resources :locations
resources :people
resources :addresses

get 'clients/new'
post 'clients'

end

When trying to render the form, I get the following error:

ActionController::RoutingError in Clients#new

Showing C:/Documents and Settings/Corey Quillen/My  
Documents/rails_projects/shop_manager/app/views/clients/new.html.erb where line #1   
raised:

No route matches {:controller=>"clients_controller", :action=>"create"}
Extracted source (around line #1):

1: <%= form_for @account, :url => { :controller => "clients_controller", :action =>    
   "create" } do |f| %>
2: 
3:   <%= f.fields_for :persons do |builder| %>
4:  <%= builder.label :first_name %><br />
  • 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-05-24T19:26:53+00:00Added an answer on May 24, 2026 at 7:26 pm

    You have to say this in routes.rb

    resources :clients
    

    In the form, specify the url as clients_path with method as post:

    <%= form_for @account, :url => clients_path, :html => {:method => :post} do |f| %>
     ---
    <% end
    

    For more information how rails handles REST urls: http://microformats.org/wiki/rest/urls

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to map a route with MapRoute and specify a generic controller
Can some one specify the windows API, one need to use in order to
I know I can specify one for each form, or for the root form
I need to convert string like this: $url = 'module/controller/action/param1/param1value/paramX/paramXvalue'; to url regarding current
Currently I use [Authorize(Roles = .....)] to secure my controller actions on my ASP.NET
I'm trying to use an Html.RenderAction in a strongly typed nature from the MVC
I'm trying to render from a pnr controller to the index of a web_services
How can I render after executing an action in a restful controller instead of
I am trying to upload files using Spring CommonsMultipartResolver however the controller is not
I have these routes defined: routes.MapRoute(CategoryList_CountryLanguage, Categories/{id}/{urlCategoryName}/{country}/{language}, new { controller = Categories, action =

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.