我遇到了一個小問題。Rails表單提交問題
我的控制器:
def new
@company = Company.new
@title = "Create company"
end
def create
@company = Company.new(params[:company])
@company.admin_id = current_user.id
if @company.save
flash[:success] = "Company created!"
redirect_to admin_path
else
@title = "New company"
render 'new'
end
end
new.html.erb
<%= debug params[:company] %>
<% form_for @company, :html => { :multipart => true } do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<%= render 'fields', :f => f %>
<div class="actions">
<%= f.submit "Submit company!" %>
</div>
<% end %>
Company.rb模型
validates :name,
:presence => true,
:length => { :maximum => 20 }
validates_attachment_presence :logo
但在提交表格後,我已經得到反正只有一個錯誤:
姓名ca不是空白
當然,我填寫名稱和標誌字段。
任何想法?謝謝。
顯示你的`_field`部分 – fl00r 2011-02-02 21:30:48