In the interest of avoiding debate over this post, let’s just say there is more than one way to skin a cat when it comes to configuration management in an application. Some like to keep it out of the code base, others prefer it. This method stores the config files in the repository.
There is more than one way to handle configuration variables based on an environment for a node.js app, but I’ve come up with a pretty simple solution that keeps my config variables DRY and complete control to override them at the same time using different node environments.
I originally tried ‘sort_by’, but that only works for existing attributes and apparently in only one direction.
My ‘is_default’ attribute is setup as a boolean and is almost always false, except where I define an image as being the default for a given product.
Converting a boolean to a string and then sorting alphabetically in reverse order is not something I liked nor recommend, but it was the first thing that I got working.
What to do if you see your PHP script relies on session side-effect error message.
I came across this error a few times, enough to where I dug around and finally found the real fix to suppress the error completely.
I am using sessions to save UI messages that can be shown to the user after an action has been formed (ie: logging in).
My initial problem was that the message persisted, while attempts to unset the session message didn’t allow for any messages to be shown.
First save the messages from the session, then you can delete them out of the session so they don’t persist past the one request.