2013-12-23 21 views
0

我在我的索引頁上有一個搜索表單,它將重定向到一個頁面,該頁面顯示所有通過搜索給出的參數的狀態。現在,如果由於搜索參數不符合我的任何狀態而導致頁面爲空白,我想要發出通知。任何想法? 格爾茨Flash [:notice] if page.blank?

回答

0

戴上閃光的通知,如果搜索的對象是零。

def search_status 
    @search = User.find_by_status(params[:status]) 
    if @search.present? 
    // Respective action 
    else 
    flash[:notice] = 'Requested status is not available' 
    rediret_to '/Index' 
    end 
end 
1

嘗試這個

@search = User.find('status', params[:status]) 

rediret_to page_path, notice: "Requested status is not available" if @search.present? 
0
def search_status 
    @search = User.find_by_status(params[:status]) 
    if [email protected]? 
    flash[:notice] = 'Requested status not available' 
    rediret_to '/Index' 
    end 
end 
相關問題