调用渲染时缺少模板错误

发布于 2024-11-25 03:19:17 字数 1281 浏览 0 评论 0原文

错误

 ForumsController create should work for plist
 Failure/Error: post :create, :name => "My New Shiny Forum", :format => 'plist'
 Missing template forums/create with {:formats=>[:plist], :handlers=>[:builder, :rhtml, :rxml, :erb, :rjs], :locale=>[:en, :en]} in view paths "/Users/maletor/Sites/3md/app/views", ..."
 # ./app/controllers/forums_controller.rb:64:in `create'
 # ./app/controllers/forums_controller.rb:61:in `create'
 # ./app/controllers/forums_controller.rb:52:in `create'
 # ./spec/controllers/forums_controller_spec.rb:222

./spec/controllers/forums_controller_spec.rb:222

post :create, :name => "My New Shiny Forum", :format => 'plist'

./app/controllers/forums_controller.rb#create

def create
  Forum.transaction do 
    if Forum.find_by_name(params[:name])
      head :conflict
      return
    end
    group = Group.create!(:name => params[:name])
    forum = Forum.create!(:name => params[:name])

    respond_to do |format|
      Rails.logger.debug "FORUM: #{forum.inspect}"
      format.json { render :json => forum, :status => 201 }
      format.plist { render :plist => forum, :status => 201 }
    end
  end
end

The error

 ForumsController create should work for plist
 Failure/Error: post :create, :name => "My New Shiny Forum", :format => 'plist'
 Missing template forums/create with {:formats=>[:plist], :handlers=>[:builder, :rhtml, :rxml, :erb, :rjs], :locale=>[:en, :en]} in view paths "/Users/maletor/Sites/3md/app/views", ..."
 # ./app/controllers/forums_controller.rb:64:in `create'
 # ./app/controllers/forums_controller.rb:61:in `create'
 # ./app/controllers/forums_controller.rb:52:in `create'
 # ./spec/controllers/forums_controller_spec.rb:222

./spec/controllers/forums_controller_spec.rb:222

post :create, :name => "My New Shiny Forum", :format => 'plist'

./app/controllers/forums_controller.rb#create

def create
  Forum.transaction do 
    if Forum.find_by_name(params[:name])
      head :conflict
      return
    end
    group = Group.create!(:name => params[:name])
    forum = Forum.create!(:name => params[:name])

    respond_to do |format|
      Rails.logger.debug "FORUM: #{forum.inspect}"
      format.json { render :json => forum, :status => 201 }
      format.plist { render :plist => forum, :status => 201 }
    end
  end
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然#的苍凉 2024-12-02 03:19:17

不要将控制器中的任何代码覆盖到事务中,它按照约定在模型层上使用。您可以在论坛模型中的 after_create 回调上创建组

Do not cover any code in controller into transaction, it uses on Model layer by conventions. You can create the group on a callback after_create in Forum model

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文