开发者

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 m开发者_如何学Codel (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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜