views:

50

answers:

1

I want to conditionally switch on/off certain functionality in my Rails app, for example in my current app I have the following functionality "product show case", "product search", "ecommerce", "user management" etc

If I implement the same app for someone else they probably might not want the ecommerce function, how do I disable the ecommerce functionality without extensively changing the code.

A raw idea that comes to mind is to have a variable in a config file that says

product search : disabled
ecommerce : enabled

and then check if ecommerce is enabled or disabled, if product searching is allowed or not and act accordingly.

But before I go ahead and do something time consuming, just wanted to make sure if there is a plugin or perhaps a more structured way of handling this scenario.

Many Thanks

+1  A: 

You could add a constant in your environment.rb:

PRODUCT_SEARCH = true ECOMMERVE = false

and then query it in your application (f.e. in routes.rb)

map.resources :product_search if PRODUCT_SEARCH
Lichtamberg