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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:44:50+00:00 2026-05-26T15:44:50+00:00

I create controller with InherritedResource class AppsController < InheritedResources::Base belongs_to :company # Devise before_filter

  • 0

I create controller with InherritedResource

class AppsController < InheritedResources::Base
  belongs_to :company

  # Devise
  before_filter :login_or_oauth_required
  # CanCan
  load_and_authorize_resource
end

and try to test it with Rspec by this method

require "spec_helper"

include Devise::TestHelpers

describe AppsController do
  before(:each) do
    @company_1 = Factory.build(:company)
    application_1 = Factory.create(:application, :company => @company_1)
    application_2 = Factory.create(:application, :company => @company_1)
    application_3  = Factory.create(:application, :company => @company_1)    
    @company_2 = Factory.build(:company)

    @user_1   = Factory.create(:user)
    role_1    = Factory.create(:publisher_role, :company => @company_1) 
    profile_1 = Factory.create(:profile, :company => @company_1, :user => @user_1, :roles => [role_1])
  end

  describe "index action" do
    it "user_1 should have 3 applications from company_1" do
      sign_in @user_1
      params = {"company_id"=>"1"}
      get :index
      assigns[:apps].should have(3).items
    end
  end
end

The result is

Failure/Error: get :index
     ActionController::RoutingError:
       No route matches {:controller=>"apps"}

How to tell Rspec to “Get” in to my nested route

My routes

  resources :companies do
    resources :apps do
      resources :shelves do
        resources :publications
      end
    end
  end

I try to follow this Question How to test controllers with nested routes using Rspec? but it’s not work on my case

I use Rails 3.1.1 and rspac 2.7

  • 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-26T15:44:50+00:00Added an answer on May 26, 2026 at 3:44 pm

    I found solution 😛

    What I did was just to change from

    get :index
    

    to

    get :index, :company_id => @company_1.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a generic controller, ie: public class MyController<T> : Controller where
Controller: class CategoriesController < ApplicationController def create @category = Category.create(...) respond_to do |format| if
I have: class Person < ActiveRecord::Base has_many :people_phones has_many :phones, :through => :people_phones end
as there is a process to create a controller or a domain class via
I am trying to create controller actions which will return either JSON or partial
What's the best way to dynamically create a controller in Rails. I've got a
what is the life of a controller? if i create a controller, store some
In my app, I create view controller objects as I need them. When a
How can I dynamically create a view controller with a NIB file? Thanks.
I learned how to create a view controller and make the view slide in

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.