ruby on rails - Uninitialized constant error while deleting multiple connected records from database -


i have following database. after user registers site new galleryphoto created him. can have 1 galleryphoto in can store multiple photos.

these models:

class user < activerecord::base   has_one :gallery_photos, :dependent => :delete   has_many :photos, :through => :gallery_photos    after_create :setup_gallery    def setup_gallery     galleryphoto.create(userid: self.id, name: self.email)    end end  class galleryphoto < activerecord::base   belongs_to :user   has_many :photos, :dependent => :delete_all end  class photo < activerecord::base   belongs_to :gallery_photo end 

after want delete user:

def destroy   user.find(params[:id]).destroy end  

i receive following error on line:

nameerror in userscontroller#destroy uninitialized constant user::galleryphotos 

gallery created after user registers , can add images it.

thank help!

modify line

has_one :gallery_photos, :dependent => :delete has_many :photos, :through => :gallery_photos 

to

has_one :gallery_photo, :dependent => :delete has_many :photos, :through => :gallery_photo 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -