Sha256: ede0cbc18f8082df754ebe4aed7e9109d954102ede434e98c49d7bebb6bdd0fc
Contents?: true
Size: 830 Bytes
Versions: 1
Compression:
Stored size: 830 Bytes
Contents
class CategoriesController < ApplicationController def index @categories = Category.all end def new @category = Category.new end def create @category = Category.new(category_params) if @category.save redirect_to categories_path else render :new end end def edit @category = Category.find(params[:id]) end def update @category = Category.find(params[:id]) if @category.update_attributes(category_params) redirect_to categories_path else render :edit end end def token categories = Category.where("categories.name like ?", "%#{params[:q]}%") respond_to do |format| format.json { render :json => categories.map(&:to_token) } end end private def category_params params.require(:category).permit! end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
token_field-2.0.0 | spec/dummy/app/controllers/categories_controller.rb |