Compatible with Rails 3
Hi,
I've added 2 commits to the main repo, allowing to:
- Show custom text for each instance found on the view (by specifying a method name to invoke, instead of just calling an attribute value)
- Making the options of auto_complete_result html_safe, so that it works well with Rails 3 apps
I tested your version and solved the problem with Rails 3.0.0
Can you please provide me with the exact steps as to how to use this plugin with Rails 3.0. I am having problems installing the plugin with Rails3.
Hi rajarmyadhav,
First of all you need to install the plugin as follows:
rails plugin install --force http://github.com/marklazz/auto_complete.git
Then, will need to setup the controllers as the docs suggests (on https://github.com/marklazz/auto_complete). For example by doing this:
Controller
class BlogController < ApplicationController auto_complete_for :post, :title .. end
Then add a route to access that helper defined in the controller, something like this: ..:Application:routes.draw do .. post "/blog/auto_complete_for_post_title" => "blog#auto_complete_for_post_title" .. end
Then you can use this view helper to point to that route (or you can specify it via :url parameter):
View
<%= text_field_with_auto_complete :post, :title %>
Then, you'll see it working. Just one minor adjustment left, to see the options fits nicely under the text_box_with_auto_complete you'll probably need to adjust the css with this:
- { margin:0; padding:0; }
Perhaps you can narrow the styles more than I did, but just to give you a simple solution on a new ralis app.
I'll update the README file with this, because I've just noticed it never mentions about the routes.