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_one
association. You should use build_map
for building a new map.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With