I'm probably doing something stupid, but...
app/model/user.rb:
class User < ActiveRecord::Base
has_one :totem
config/routes.rb:
resources :users do
resource :totem
end
app/controllers/totems_controller.rb:
class TotemsController < ApplicationController
before_filter do
@user = User.find(params[:user_id])
end
def new
@totem = @user.build_totem
end
end
app/views/totems/new.html.erb:
<%= form_for [@user, @totem] do |f| %>
<% end %>
Then, when I navigate to /users/123/totem/new
, I get the error:
ActionView::Template::Error (undefined method `user_totems_path' for #<#<Class:0x007f9d3c843b00>:0x007f9d3bb6dd68>):
But because I'm using resource :totem
instead of resources :totems
in routes.rb, the path helper it should be using is user_totem_path
. Why isn't it trying to use the correct path helper?