I have the following models, Member and Map, set up as so:
class Member < ActiveRecord::Base
...
has_one :map, :dependent => :destroy
...
class Map < ActiveRecord::Base
belongs_to :member
and my routes are set up with:
resources :members do
resources :maps
end
and my maps controller is:
def new
@map = Map.new
end
def create
@map = current_member.map.new(params[:map])
if @map.save.....
But when I try to save a new map, I get an error undefined method 'new' on that create line. Im not sure why.
Here is a description of all methods added by
has_oneassociation. You should usebuild_mapfor building a new map.