yaml_form_builder

Posted by anup.narkhede on October 13, 2007

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.

Prototype Window Login Form with Ajax/RJS

Posted by anup.narkhede on March 01, 2007

Here is a simple tutorial to demonstrate the use of prototype Window login form with RubyOnRails and Ajax. The idea behind this is to override Ok event of Dialog.confirm() form and send Ajax request to controller. The demo application makes use of RJS for Ajax callbacks.

See Live Demo


To begin with, download prototype windows library, copy javascripts in your public/javascripts folder and themes to stylesheets folder.

Include the javascripts and stylesheets in layout header.Look at our application.rhtml layout for complete details.

Continue reading…

Dynamic Subdomains with Ruby on Rails

Posted by anup.narkhede on December 30, 2006

Following is a step by step guide to configure an application for dynamic subdomains. We are trying to set up wildcard subdomain feature similar to the one done by blogspot.com and wordpress.com.

Step 1
In advanced DNS settings of your domain, add an A record as follows
*.domain.com IN A ***.***.***.*** (server IP address)

Step 2

Modify http.conf to set up a serveralias *.domain.com for http://www.domain.com/.
Make sure you have access, or ask your service provider to do this.

Step 3
Add a wildcard entry for your domain in the Zone file for http://www.domain.com/, so that nonexistant subdomains are resolved to same public_html folder.

Now to check this, keep an index.html file in the public_html folder.
Try browsing http://www.domain.com/ and http://anything.domain.com/ . Both should resolve to the same index.html file. If this succeeds, your dynamic subdomains are set up.

To catch the subdomain in RubyOnRails modify application.rb as follows,

Now you have a subdomain catched by your application controller which can be used in all controllers.
For example, MyController makes use of @subdomain and decides what action to take. (it is a simple redirect action in this case)