Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No route matches" error?

I am new Rspec and just started by generating a new controller on Rails 3. It generates some Rspec tests by default. I have a question about how to make them pass though. As it stands, I see this test in my terminal"

1) BuildingsController GET 'show' should be successful

 Failure/Error: get 'show'
 No route matches {:controller=>"buildings", :action=>"show"}
 # ./spec/controllers/buildings_controller_spec.rb:17:in `block (3 levels) in <top (required)>'

However, I don't understand why it's coming up because I already have this route created ("resources :buildings"), and I ran rake routes and made sure it's there.

building GET /buildings/:id(.:format) {:action=>"show", :controller=>"buildings"}

What is necessary to make this pass? Here is the test by the way:

  describe "GET 'show'" do
    it "should be successful" do
      get 'show'
      response.should be_success
    end
  end
like image 626
picardo Avatar asked Jan 07 '11 17:01

picardo


People also ask

What does routing error mean?

Getting a "Routing Error" message means the parameters linked to your Terminal ID have not been fully configured or have been disabled due to inactivity on the terminal.

How do I see all routes in Rails?

TIP: If you ever want to list all the routes of your application you can use rails routes on your terminal and if you want to list routes of a specific resource, you can use rails routes | grep hotel . This will list all the routes of Hotel.


1 Answers

You need to pass id of existing building: get :show, :id => @building.id

Routes complain about it because :id isn't optional.

like image 62
Heikki Avatar answered Sep 21 '22 12:09

Heikki