Using AutoComplete with ActiveScaffold forms
This is a quick guide to set up auto_complete text fields in forms rendered by ActiveScaffold plugin.
I am not a huge fan of ActiveScaffold, but found these steps worth publishing after doing this for one typical project requirement.
1. Models
2. Install ActiveScaffold and AutoComplete Plugins
3. Controller Configuration
This renders a drop down list for country field, instead of the default create/replace form. However, we need to render an auto completing text box for which we need to replace the form column.
4. Form column override
Next step is to override the form column. Create a file named _country_form_column.html.erb in app/views/cities folder.
The second option :method => :get is needed to avoid the InvalidAuthenticityToken error generated by the ajax post request.
5. Since the form now returns country[name] instead of record[country_id] in params, we need to assign country object before creating city record. The CitiesController finally looks like:
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.
Client for Yahoo! Search webservices in RubyOnRails
Here is a client for Yahoo search api using the simplest web service architecture REST (Representational State Transfer).
Working demo: http://demo.anup.info/search
The client application works as:
To begin with, get an application ID from http://developer.yahoo.com.
Controller: search_controller.rb
View: index.rhtml
Partial view: _results.rhtml
Partial View: _error.rhtml
Prototype Window Login Form with Ajax/RJS
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.
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.
Prototype Ajax with Apache Struts
A simple example of Ajax on Struts using prototype.js
ScrapLogger is a simple example of integrating prototype and scriptaculous effects with struts. The logger is a demonstration of single ajax updater call, and scriptaculous Highlight effect.
My Java struts application contain a single action class, one form bean and two JSPs.


