调用渲染时缺少模板错误

时间:2011-07-19 19:54:36

标签: ruby-on-rails ruby ruby-on-rails-3 rspec capybara

错误

 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

./规格/控制器/ forums_controller_spec.rb:222

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

./应用程序/控制器/ forums_controller.rb#创建

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

1 个答案:

答案 0 :(得分:1)

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

中的回调after_create上创建组