“render new”和“render new.html.erb”之间有什么区别吗?

时间:2015-06-03 16:22:00

标签: ruby-on-rails ruby

我的create控制器中有users个动作:

def create
  @user= User.new(user_params)
  if @user.save
    #success action filled
  else
    render 'new'
  end
end

和测试以检查错误无效用户的模板是否通知:

test "user input error" do
  get signup_path
  assert_no_difference 'User.count' do
    post users_path,user:{name:"raj",email:"sad",password:"sad",password_confirmation:"sad"}
  end
  assert_template 'new'
end

正在过世。但是当我将render new更改为render new.html.erb时,它会失败。

expecting <"users/new.html.erb"> but rendering with <["shared/_error_messages", "users/new", "layouts/_shim", "layouts/_header.html.erb", "layouts/_footer.html.erb", "layouts/application"]>

这些是页面中的其他布局。有人可以解释为什么会这样吗?

0 个答案:

没有答案