私のTokeninputオートコンプリートフィールドで、返された列を自分のものと、定義された方法で行ったときの両方にしようとして:address
い:website
ます:store
。
class BusinessStore < ActiveRecord::Base
scope :search_by_store, lambda { |q|
(q ? where(["address LIKE ? or website LIKE ? like ?", '%'+ q + '%', '%'+ q + '%','%'+ q + '%' ]) : {})}
def store
if self.online_store
"#{business_name} - #{website}"
else
"#{business_name} - #{address}"
end
end
end
class BusinessStoresController < ApplicationController
def index
@business_stores = BusinessStore.all
@business_stores = BusinessStore.search_by_store(params[:q])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @business_stores }
format.json { render :json => @business_stores.collect{|b|{:id => b.id, :name => b.store } } }
end
end
end
私のjsonページ:http://localhost:3000/business_stores.json
すべての結果が正しく表示されますが、トークンフィールドには:address
結果のみが表示され、Webサイトの結果は表示されません。これを修正するにはどうすればよいですか?