简体   繁体   中英

Rails 3 Engine - using models from main app?

I'm new in Rails development. I've just created really simple Rails App and Rails Engine (which only displays static text with this example: https://github.com/mankind/Rails-3-engine-example ). I am wondering if it is possible to use the user model from main app inside the engine. If it is no clear... for example I want to get logged user data inside my engine. Is it possible, and how?

Engine is an Rails App itself so how can I develop engine without model (for example user model) from my main app? Any sugestions?

Yes it's possible like in your core app.

The code inside an engine works the same way as in the app itself so I guess you'd use before_filter to check this.

I highly recommend you use a dummy app to test the engine you are coding. Look at my gem here: https://github.com/apneadiving/Google-Maps-for-Rails

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM