ruby - Rails Joins through a module -
I have a lot in my model to list all 'places' in my model with a "post" Something trying to make it easier to add.
Currently, each post has_many: places,: through = & gt; : Location_post . I am using the 'Blogite' gem, which posts a module in 'Blogit :: Posts'.
I get a wrong logic type class (expected module) error when I try to run the following in my Post.rb model:
module blogit class post & lt; ActiveRecord :: Base before_save: reuse_existing_locations def reuse_existing_locations current_space = location.include (Blogit :: Post). First end How can I connect through a module?
Thanks in advance!
I'm not sure why I think you're trying to do some notes and Overview:
- By looking at it, it is clear that
Blogit :: Postis a class, not a module. -
Addtakes the method module (not square), this is the error you are seeing. - You are calling
includedmethod tolocationmodel and what makes me feel weird is calling you? But again it does not matter too much because it seems that there are links betweenmanyandBlogit :: Post many>. -
In the
locationmodel (which is not required to be in theBlogitnamespace), you can onlyblogit :: postmodel is as follows:is_im: post, class_name: "blogto :: post", ... -
If
existing_spaceis actually a feature on the model and you want to specify it, then you should putselfin front of it (asself.existing_locationsis in). Otherwise you are just building a local variable.
Comments
Post a Comment