When does the Plugin.rb run?

sorry for my question but it is annoying me for long time.
in plugins I use JS. in javascript we our code run in special event for example when we use outlets we now our code will run when the outlet is shown.
but for plugin.rb I think this code will run just at the beginning of the app.
can anyone one help me when else this code will run?

That’s right.

I suggest you become familiar with Ruby on Rails. Their guides are pretty good.