Currently, for my project, I'm using different services like for SMS, Push Notification etc...
So I would like to know a way to restrict this service calls based on the environment which I'm currently in.
let's say if the current environment is production
obviously we need all service to be work as expected but it may not necessary for other environment.
So I would like to know some way to restrict that service to the specific environment only rather than making it available for all environment. I know as a conditional
basis we know we can check it by:
Rails.env.production?
But for this, we are actually modifying the code which is not a good practice to do. I don't want to make it that way or change the actual code. what I'm thinking is intercept the external API request of the service or do some action like giving a preview. I'm not sure that's the better approach if you have any suggestion you can shoot also.
The behaviour of letter opener gem
is something like that in development
instead of sending a mail it opens a preview for us.
I also found this solution in SO Rails 3: How to intercept any HTTP request if possible can someone explain how this working.