Toddsqui
Toddsqui

Reputation: 59

NoMethodError in Places#Show (Ruby on Rails)

So I'm trying to create the ability for users to add comments and upload photos to their pages, but I keep getting this NoMethodError in Places#show error. It says the following (and I'm quoting the error page):

undefined method `place_photos_path' for #<#<Class:0xb5d58300>:0xb5642930>

And then shows me the line of code where the issue is apparently located:

  <h4 class="modal-title" id="myModalLabel">Add a comment</h4>
          </div>

        <%= simple_form_for @photo, :url => place_photos_path(@place) do |f| %>
          <div class="modal-body">
            <%= f.input :caption %>
         </div>

It highlights the simple_form line as being the line in question. I'm really stuck. Any help would be so much appreciated.

Here is the config/routes.rb file:

Findmygirlfriend::Application.routes.draw do
  devise_for :users
  root 'places#index'
  resources :places do
    resources :comments, :only => :create
  end
  resources :users, :only => :show
  resources :photos, :only => :create
end

Thanking you in advance.

Upvotes: 0

Views: 262

Answers (1)

Alex Antonov
Alex Antonov

Reputation: 15156

Just place your resources at the right scope. This should help

Findmygirlfriend::Application.routes.draw do
  devise_for :users
  root 'places#index'
  resources :places do
    resources :comments, :only => :create
    resources :photos, :only => :create
  end
  resources :users, :only => :show
end

Upvotes: 1

Related Questions