Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 334
radzio Avatar asked Mar 09 '26 05:03

radzio


1 Answers

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

like image 175
apneadiving Avatar answered Mar 10 '26 21:03

apneadiving



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!