我使用formtastic驗證形式:軌道/ Formtastic - 確認不存在的
<%= semantic_form_for @user do |f| %>
<ul class="formItem">
<%= f.input :username, :required => true, :label => "Your Username", :input_html => { :class => 'double' } %><br clear="all" />
<p class="fieldExplanation">Your username is made public to other people on the site.</p>
</ul>
<ul class="actions">
<%= f.commit_button("Save my profile and make a match >", :class => "submitForm") %>
</ul>
<% end %>
它的視覺工作 - 形式一點點呈現星號來表示,它理解:要求=>真 - 但是當頁面發佈時,它不會觸發具有錯誤的驗證;相反,它只是轉到下一頁,就好像它是成功的。
我覺得我錯過了一個簡單的設置某處開啓驗證,或者我在我的控制器中做錯了什麼?
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(match_user_path(@user), :notice => 'User was successfully updated.') }
else
format.html { render :action => "edit" }
end
end
end
在此先感謝。
我開始認爲別的東西壞了 - 當我包含'<%= f.input:mySelectBox,as =>:select,:collection => [「Thing one」,「Thing two」]%> '我得到了**未定義的局部變量或方法'as'for#<#:0x837a368> ** –
Jon
2011-06-11 15:59:51