0
貼我有一個簡單的表格,我想用搜索姓氏:Rhomobile的:沒有PARAMS正在從形式
<form method="POST" action="<%= url_for :action => :index %>">
<label for="surname" class="itemLabel">Search Surname</label>
<input type="text" id="surname" name="surname" class="" <%= placeholder("Surname") %> />
<input type="submit" value="Search"/>
</form>
在控制器指數法,我有以下代碼:
def index
if @params['surname'].nil? or @params['surname'].empty?
@fencers = Fencer.find(:all)
else
@fencers = Fencer.find(:all, :conditions => {:surname => @params['surname']})
end
render :back => '/app'
end
如果它有一個姓氏param,那麼它會搜索,如果沒有,它將只顯示所有可用的。當我調試這個動作時,在發佈搜索表單後被調用時,我從來沒有看到任何參數。
此搜索表單基於自動生成的登錄表單(工作),所以我有點困惑。有任何想法嗎?
謝謝我會試試這個。 – digitalWestie
完美無缺! – digitalWestie