Want to modify rails code of discourse application

I want to modified the code of discourse from backend and change scope of some model but it will not reflect on UI, how can I modify the backend code of discourse application.
Like I want to change the scope of some models based on my requirement want to change queries from backend, I am able to do on rails console but not able to implement on code base.
Guide my the steps.

You should create a plugin (look at example repos linked in plugin) so that core upgrades work as normal. Do not modify the source code ‘directly’ as that will make maintenance a total pain. Use the guides in developers to get going. Rails Serializers will need expanding if you want to bring down more data. However consider Custom Fields if your needs are light.