Create recursive OpenStruct from a Ruby Hash
#
Tags:
Maybe you already know and used the Ruby's OpenStruct class. I've played a bit with it to create a very easy to use configuration system for Ruby apps.
Maybe you already know and used the Ruby's OpenStruct class. I've played a bit with it to create a very easy to use configuration system for Ruby apps.
Rails 4 will use StrongParameters by default. However, it doesn't seem that Devise is ready for this feature, even using its rails4 branch. There's a good example that explains how to solve this problem when dealing with only one resource (eg: User). I forked that code to handle more resources (eg: User and Admin) without repetitions.
Uploading images with custom sizes on different models is a very common task during web development. Every time, people uses different image uploaders for each model, where the only difference is about sizes. I'd like to share a simple hack to DRY code with some metaprogramming.
When it comes to develop a CMS, one of the main problems concerns where or how to store and organize views (templates, partials, layouts) for particular needs like different layouts for specific pages, (sub)domains or multi-languages.
In the last post, I explained how to make conditional searches based on conditional params. I wrote a very simple Search class that returns a real model with query done by Arel. I refactored the code to make it simpler to use.