Rails Engines - simple possible engine to (1) add a model and (2) add the association in the containing class -


i trying write first engine having problems following scenario. in host app, have user model (this guaranteed in engine can refer user class rather level of indirection) has name. in engine, have post model , need create association between post model , user model in containing app.

>rails plugin new abc --mountable ... >rails g model post header:string body:text user_id:integer 

... edit post file:

module abc   class post < activerecord::base     attr_accessible :body, :header, :user_id     belongs_to :user      def self.say_hello       puts "hello: " + object.const_get(user).to_s     end   end end 

how access user model in containining class add following?

has_many :abc_posts, class: "abc::post" 

i have tried every variation of having in engine (at app/models/ app/models/abc etc....):

class user < activerecord::base   has_many :abc_posts, class: "abc::post" end 

but no avail. how work?

thx in advance


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -