0
I have the following haml code in index.haml
%nav.breadcrumbs
%h2 Breadcrumbs
%br
-if @invalid
%p.error{role: 'alert'} some alert
%p.info{title: 'Important Notification', role: 'status'} Some information
-else
%p.info{title: 'Important Notification', role: 'status'} Some information
%section.form
%form.standard{action: root_path, method: 'get'}
%fieldset.search{'aria-labelledby' => 'content-header'}
%input{type: 'search', name: 'name', role: 'textbox'}
%fieldset.input-actions
%input.primary-action{type: 'submit', value: 'search', name: 'invokeSearch'}
-if @accounts.blank?
%h3 #{'Result Not Found'}
-else
= render 'some_path/path'
條件我在我的控制器如何重定向到同一頁面取決於軌道
def index
@invalid = !!(params[:name] =~ /[=,\/\\]/)
if @invalid
redirect_to index_path
end
以下檢查我不知道如果我在這裏做幹啥,是錯誤的。我想在頂部顯示錯誤並重新發布到同一頁面。
在這種情況下,您不需要'redirect_to'。只是'閃光[:錯誤] =東西,如果@無效' – prusswan