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 :: Post
is a class, not a module. -
Add
takes the method module (not square), this is the error you are seeing. - You are calling
included
method tolocation
model and what makes me feel weird is calling youmany
andBlogit :: Post many
>. -
In the
location
model (which is not required to be in theBlogit
namespace), you can onlyblogit :: post
model is as follows:is_im: post, class_name: "blogto :: post", ...
-
If
existing_space
is actually a feature on the model and you want to specify it, then you should putself
in front of it (asself.existing_locations
is in). Otherwise you are just building a local variable.
Comments
Post a Comment