我tags
在我的 Rails 应用程序中使用 jQuery Tokeninput。我以前从未处理过 JSON(我是编程新手),但我想知道是否有一种方法可以创建然后用 .json 中的字符串值填充一个 json 文件Profile.all
。
这是index
我的TagsController
:
class TagsController < ApplicationController
def index
@tags = Tag.where("name like ?", "%#{params[:q]}%")
respond_to do |format|
format.html
format.json { render :json => @tags.map(&:attributes) }
end
end
end
如果可能的话,有人可以给我一个关于如何完成的想法吗?如果需要更多代码,请告诉我!
说明:我想这样做的原因是为了限制@tags
已经存在的标签。