Ruby on rails 呈现json错误

Ruby on rails 呈现json错误,ruby-on-rails,ruby,Ruby On Rails,Ruby,render json不工作我遇到以下错误 def tag_autocomplete @tags = Tag.find_by_sql("SELECT tag_name as id,tag_name as label,tag_name as value FROM tags ") render :json => @tags.to_json end 我使用的是ruby 1.8.6和rails 2.3.5 提前感谢检查这是否有帮助 Argument

render json不工作我遇到以下错误

   def tag_autocomplete
        @tags = Tag.find_by_sql("SELECT tag_name as id,tag_name as label,tag_name as value FROM tags ")
        render :json => @tags.to_json
     end
我使用的是ruby 1.8.6和rails 2.3.5

提前感谢

检查这是否有帮助

ArgumentError (wrong number of arguments (0 for 2)):
    /app/controllers/tags_controller.rb:32:in `to_json'
编辑

它可能是sql语句或类成员命名。请把你的标签贴出来好吗

试试这个。如果有效,则表示类和变量名与db列不匹配。您可以在module\class中修复该问题,以指示列名

format.json { render json: @tags }

实际上,您不需要使用json。 render:json=>@tags
就足够了

谢谢您的回复。我也尝试过这个错误,但同样的错误您的标记模块是什么样子的?您是否有可能在model
tag
中重写
to_json
方法?
@tags = Tag.all
render :json => @tags