Populate a JSON file with Rails fields in Profile.all

I’m using jQuery Tokeninput for tags in my Rails app. I have never dealt with JSON before (I’m new to programming) but I was wondering if there was a way to create then populate a json file with string values from Profile.all.

Here is the index in my 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

If it is possible, can someone give me an idea of how it might be done? If more code is needed let me know!

newest questions tagged jquery – Stack Overflow

About Admin