在我的Business
模型中,当我尝试创建业务并发生错误时,我注意到在 POST 之后它摆脱了我的shared/page_header
部分:
def page_title
"#{@page_title}"
end
<% unless @page_title.blank? %>
<div class="row">
<div class="page-header span12">
<h1><%= @page_title %></h1>
</div>
</div>
<% end %>
def new
@business = Business.new
@page_title = "Add Business"
end
def create
@business = Business.new(params[:business])
if @business.save
redirect_to :back, :notice => "This Business was successfully added."
else
render :new, :notice => "It seems there was an error. Please try again."
end
end
现在我注意到我开始/businesses/new
但在 POST 之后它转到/businesses
. 有人告诉我这很正常,但直到现在我才看到这种行为。如果有帮助,new
and操作是我资源create
中唯一的操作。Business
我该怎么做才能让它工作?