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 to location model and what makes me feel weird is calling you ? But again it does not matter too much because it seems that there are links between many and Blogit :: Post many >.
  • In the location model (which is not required to be in the Blogit namespace), you can only blogit :: 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 put self in front of it (as self.existing_locations is in). Otherwise you are just building a local variable.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -