My nested resource is farm. In my routes I have:
resources :users do
resource :farm
end
devise_for :users, :path => 'accounts'
So, the devise paths for sign up, etc are working and not making problems. But when I try to make a new farm, I get this error:
undefined method `farm_user_path' for #<#<Class:0x463d8f8>:0x46493e8>
I am accessing it via:
<%= link_to "New Farm", new_user_farm_path(current_user) %>
In my farm controller, I have:
class FarmsController < ApplicationController
# GET /farms
# GET /farms.json
include Devise::Controllers::Helpers
helper_method :current_user
def new
@farm = Farm.new
@user = User.find(current_user)
respond_to do |format|
format.html # new.html.erb
format.json { render json: @farm }
end
end
...
end
And my form for making new farm is :
<%= form_for([@farm, @user]) do |f| %>
...
All of the associations and routes are ok. What am I missing?
Found the solution. Problem was that my form needed to look like this: