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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:48:37+00:00 2026-05-23T19:48:37+00:00

I have 2 controllers that I created using scaffold generator of rails. I wanted

  • 0

I have 2 controllers that I created using scaffold generator of rails. I wanted them to be nested in a folder called “demo” and so ran

rails g scaffold demo/flows
rails g scaffold demo/nodes

Then I decided to nest nodes inside flows, and changed my routes file like so:

namespace :demo do 
  resources :flows do
    resources :nodes
  end
end

But this change resulted on the rspec tests for nodes breaking with ActionController::Routing errors.

  15) Demo::NodesController DELETE destroy redirects to the demo_nodes list
     Failure/Error: delete :destroy, :id => "1"
     ActionController::RoutingError:
       No route matches {:id=>"1", :controller=>"demo/nodes", :action=>"destroy"}

The problem is rspec is looking at the wrong route. It’s supposed to look for “demo/flows/1/nodes”. It also needs a mock model for flow, but I am not sure how to provide that. Here is my sample code from generated rspec file:

  def mock_node(stubs={})
    @mock_node ||= mock_model(Demo::Node, stubs).as_null_object
  end

  describe "GET index" do
    it "assigns all demo_nodes as @demo_nodes" do
      Demo::Node.stub(:all) { [mock_node] }
      get :index
      assigns(:demo_nodes).should eq([mock_node])
    end
  end

Can someone help me understand how I need to provide the flow model?

  • 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-23T19:48:38+00:00Added an answer on May 23, 2026 at 7:48 pm

    You have two different questions going on here, so you may want to split them up since your second question has nothing to do with the title of this post. I would recommend using FactoryGirl for creating mock models https://github.com/thoughtbot/factory_girl

    Your route error is coming from the fact that your nested routes require id’s after each one of them like this:

    /demo/flows/:flow_id/nodes/:id
    

    When you do the delete on the object, you need to pass in the flow ID or else it won’t know what route you are talking about.

    delete :destroy, :id => "1", :flow_id => "1"
    

    In the future, the easiest way to check what it expects is to run rake routes and compare the output for that route with what you params you are passing in.

    demo_flow_node  /demo/flows/:flow_id/nodes/:id(.:format)   {:action=>"destroy", :controller=>"demo/flows"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Rails 3.1.0, with Active Scaffold (from the git repo). My controllers have code
I have created a new method in one of the project's controllers that it
I have a simple controller that was created through a scaffold and has a
I have a controller called 'exposures' which I created automatically with the script/generate scaffold
I have created an iPad app that has 10 view controllers that swipe left
Using Ruby on Rails, I have created a blog. The blog has posts, and
I'm using ASP.NET MVC 3 (Razor) and have created a Controller named Controllers -
I have created a tabbarcontroller (with its default two view controllers) using interface builder
I'm using rails 3.2.3 and have a questions about queries. I've read that it
I have many controllers that will have some similar behavior, e.g. the user should

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.