1
我使用的是activeadmin,無論出於何種原因它不像我的Tag模型。我沒有看到任何不尋常的事情嗎?谷歌處理不當證明有用未定義的方法`重新排序'爲#<Array:0x007fee740c1b78>
application_controller
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :get_tags
private
def get_tags
@tags = Tag.all
end
end
tags_controller
class TagsController < ApplicationController
def search
@tags = Tag.where("name like ?", "%#{params[:q]}%")
respond_to do |format|
format.json { render :json => @tags.to_json(:only => [:id, :name]) }
end
end
def show
@tag = Tag.find(params[:id])
@title = @tag.name
end
end
標籤模型
class Tag < ActiveRecord::Base
self.include_root_in_json = false
has_many :resource_tags
has_many :resources, :through => :resource_tags
attr_accessible :name
validates :name, :presence => true,
:length => { :within => 2..20 },
:uniqueness => { :case_sensitive => false }
end
完整跟蹤:http://pastie.org/3641717
你可以發佈堆棧跟蹤嗎? – 2012-03-21 04:43:15
ActiveAdmin中的哪個位置出現錯誤?你是否在視圖的索引方法上打這個?另外,你使用的是什麼數據庫?對於rails所使用的一些不太常見的數據庫(SQL Server)有一些「特殊」問題。 – 2012-03-21 12:18:17
管理區域中的所有內容都很完美,直到我點擊「標籤」標籤。我正在開發中使用sqlite3。該標籤也可以在實際網站的前端完美工作 – Tallboy 2012-03-21 14:27:49