Project

tokenizes

0.0
No commit activity in last 3 years
No release in over 3 years
This gem provides the tokenizes(relation) method for Models to specify their tokenized resources to create token-fields. It provides further a helper to create tokenized tags
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0

Runtime

>= 0
~> 3.0
~> 0.14
 Project Readme

tokenizes

This rails-gem helps to use jquery.tokeninput with active-record.

Usage

Installation

  1. require 'tokenizes' in your gemfile
  2. run 'rails g tokenizes:install' to install the tokenizes javascripts and stylesheets

the Model

Go to the model that tokenizes a relation and call 'tokenizes relation' where relation is the name of the relation you want to tokenize

the Controller

Add REST to the controller for the target of this relation. there are few requirements about the output format and the query string. See jquery.tokeninput for details. you might want something like this:

def index
  @books = Book.where("title like ?", "%#{params[:q]}%")  
  respond_to do |format|  
    format.html  
    format.json { render :json => @books.map(&:attributes) }
  end
end

the View

In your views you can call tokenize_tag(element, relation, pre=nil) of the ApplicationHelper. It will generate the tokeninput field with ujs all this work is for :)

Troubleshooting

As tokenizes optimizes the work with active record, you won't be able to use another ORM.

There are problems with conflicting jquery versions...any ideas?

Copyright (c) 2011 Bastian Kruck, released under the MIT license