0
我在关注Ruby getting started guide,第5.10节要求我们添加代码以检查添加到模型中的数据是否有效,如果不是,那么我们应该调用render'new'来刷新与用户数据页面:网址在渲染视图时发生变化
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
我注意到,虽然那一刻我从提交错误的数据我的网址更改:
http://localhost:3000/articles/new到http://localhost:3000/articles,这是为什么?渲染似乎工作,因为我得到的错误消息表明我的无效输入就像在教程中。
html输出也略微偏离,其中一个标签和文本输入字段之间有一个额外的空间。
我该如何去改变网址有/新呢? –