I'm trying to run the tokeninput plugin on a field.
First of all the tutorial is mainly around adding id's from another associated model. I do not want to do that but just use a field from my own model (table) called tags
.
currently when i type it it actions a /notes/tags.json ajax call but nothing is being returned, am i doing it right?
Controller:
class NotesController < ApplicationController
helper_method :sort_column, :sort_direction
respond_to :html, :json
def index
@notes = Note.search(params[:search]).order(sort_column + " " + sort_direction).paginate(:per_page => 5, :page => params[:page])
@tag = Note.where('tag LIKE ?', "%#{params[:q]}%")
end
Model:
class Note < ActiveRecord::Base
attr_accessible :name, :tag
def self.search(search)
if search
where('name LIKE ?', "%#{search}%")
else
scoped
end
end
end