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 8520309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:29:53+00:00 2026-06-11T06:29:53+00:00

My new and edit pages for multiple levels of nested resources all worked fine

  • 0

My new and edit pages for multiple levels of nested resources all worked fine when I had a flat resource structure. Since nesting resources for the purpose of making a more logical structure, these pages have been a bit broken.
I have a single form template for each model which starts as this:

<%= simple_form_for @contact, html: {:class => "well form-vertical"} do |f| %>

This works perfectly for the non-nested resources (such as Contact, as above), allowing create and update actions to work as expected.

With the nested resources however (such as Service, as below), the new action stops working. When I browse to the ‘new’ page, I get the error:

Error 500: undefined method `services_path' for #<#<Class:0x0b3512b4>:0xb42b2c58>

My routes.rb for the relevant section is as follows:

resources :contacts,   shallow: true,     :except => [ :destroy ] do
  resources :accounts, shallow: true,     :except => [ :destroy ] do
    resources :services,                  :except => [ :destroy ]
  end
end

The controller actions for new and edit for contacts and services are:

Contact:

def new
  @contact = Contact.new
...
def edit
  @contact = Contact.find(params[:id])

Service:

def new
  @service = Service.new(account_id: params[:account_id])
...
def edit
  @service = Service.find(params[:id])

The relevant output from rake routes is:

   account_services        GET    /accounts/:account_id/services(.:format)         services#index
                           POST   /accounts/:account_id/services(.:format)         services#create
new_account_service        GET    /accounts/:account_id/services/new(.:format)     services#new
       edit_service        GET    /services/:id/edit(.:format)                     services#edit
            service        GET    /services/:id(.:format)                          services#show
                           PUT    /services/:id(.:format)                          services#update
           contacts        GET    /contacts(.:format)                              contacts#index
                           POST   /contacts(.:format)                              contacts#create
        new_contact        GET    /contacts/new(.:format)                          contacts#new
       edit_contact        GET    /contacts/:id/edit(.:format)                     contacts#edit
            contact        GET    /contacts/:id(.:format)                          contacts#show
                           PUT    /contacts/:id(.:format)                          contacts#update
  • 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-11T06:29:55+00:00Added an answer on June 11, 2026 at 6:29 am

    As it turns out, this was entirely the wrong approach to be taking to this problem. I instead rewrote my create routes to POST straight to /:controller and it then worked with just using simple_form_for @contact, html: {class: "well form-vertical"} do |f|

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

Sidebar

Related Questions

I want to add a new form to the edit customer page, so far
I have some CRUD routing: /news/{page} // public /news/new // private /news/{slug}/show //public /news/{slug}/edit
my line in gridview <asp:Label ID=Label2 runat=server Text='<%# new System.Text.StringBuilder(<a href=\/Administration/Pages/EditPage/?pageID=).Append(Eval(PageID)).Append(\>).Append(Eval(Name)).Append(</a>).ToString() %>'></asp:Label> fails with
Say I have two fields in a new or edit form: <%= f.text_field :email
EDIT: I added in where I create new instance of the class Process as
Whenever I try to edit existing or create new distribution provisioning profile on iOS
Why new()/delete() is slower than malloc()/free()? EDIT: Thanks for the answers so far. Please
EDIT : proper solution: void add(Student s) { if(root == null) root = new
new_story GET /story/new(.:format) {:action=>new, :controller=>stories} edit_story GET /story/edit(.:format) {:action=>edit, :controller=>stories} story GET /story(.:format) {:action=>show,
edit/operacoes.php header('Content-Type: application/json'); include('../../lib/mysql.class.php'); $db = new MySQL(); if($db->Error()) $db->Kill(); //VARIÁVEIS DA FORM $id

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.