【发布时间】:2026-01-28 08:40:01
【问题描述】:
我正在使用一个 Rails 3 控制器,它有一个非常具体、有限的用途,我只需要它响应 response_to :json。
这个截屏视频说我的控制器可以从 ActionController::Metal 继承,然后只包含我需要让事情变得更快的功能: http://rubyonrails.org/screencasts/rails3/action-controller
当我的控制器看起来像这样时:
class FoldersController < ActionController::Metal
respond_to :json
def all
respond_with Folder.all
end
end
我得到错误:
undefined method `respond_to' for FoldersController:Class
我尝试过包括 Responder、ActionController::Responder、ActionController::Metal::Responder,但它们都不起作用。要获得此响应程序功能,我需要包含哪些内容?
【问题讨论】:
标签: ruby ruby-on-rails-3 actioncontroller