Remote file storage using File Column plugin
Many times I came across a need to fetch remote data (video files/images) and store them on file system. Searching for a way, I came up with this approach.
The example is about a Video class with a video_file ‘file_column’. To fetch and store a remote file instead of getting it as a post parameter, we need to do some code workaround. The example below demonstrates one approach.
Usage:
My model looks as simple as this:
JS based easy Field Validations in Rails
Most of you will disagree with this post to use Javascript based form validations in Rails. However this is an attempt to simplify integration of DEXAGOGO - Really easy field validations in Rails. This is one of the most structured and easy validation technique written by Andrew Tetlaw and team. (Demo)
To use it in Rails, copy simple_validation.rb in application lib directory and add following lines to config/environment.rb file.
Download and Import validation.js along with prototype.js in layout from here.
Two methods are introduced to render forms.
- validated_form_for
- validated_remote_form_for
Usage:
:class attribute refers to validation rule (or combination of rules) and :title attribute is the validation message. Details of all rules are available at http://tetlaw.id.au/view/javascript/really-easy-field-validation
Ajax Tree Plugin
Introduction
This is a helper plugin to generate ajax based tree structure (two level). It can be used for two models having n:m or 1:n relationships. A leaf from any branch can be dragged and dropped in another branch. A scaffolding arrangement is also done to create a new branch, add leaf etc.

For example:
Installation:
Here we take the previous example of Category and Article models. Generate the ajax controller for the two models.
Usage
Example
Copy static files
Copy add.png, delete.png from /vendor/plugins/ajax_tree/ directory to /public/images directory.
Copy ajax_tree.css file from /vendor/plugins/ajax_tree/ directory to /public/stylesheets/ directory.
Include css in your application layout
Call the helpers
Specify model names for branch model and leaf model in /views/home/_show_ajax_tree.rhtml partial.
Then, call this partial in any rhtml, where you want to display the ajax tree. In this case, we have done it in /views/home/index.rhtml
home_controller.rb (Generated automatically)
index.rhtml
Contributions:
This project is hosted at http://code.google.com/p/ajax-tree/. Please leave your feedback.
yaml_form_builder
This plugin provides a simple way to generate dynamic forms in view. The forms are configured with the help of a yaml configuration file.
1) Installation
2) Configuration
The example below demonstrates a form generated for the following schema.
3) Configuration
Create a file named formconfig.yml in /config directory.
4) Controller
Fetch records in the controller.
5) Finally the helper in View
(views/form/index.rhtml)
The url /form/index shows a form, generated dynamically with the help of above yml configuration file.


