我有一个路径/user_management/edit_official/:id
来自rake routes
的相应输出
user_management_update_official POST /user_management/edit_official/:id(.:format) {:controller=>"user_management/employees", :action=>"update_official"}
当我尝试通过表单访问网址时,未达到网址,因为网址/user_management/edit_official/:id
成为参数。
以下是日志文件条目?
为127.0.0.1 at开始POST“/ user_management / edit_official / 31” 2012-01-02 11:05:21 +0530由ErrorsController处理#index为 HTML
参数:{“utf8”=>“✓”, “authenticity_token”=> “中DED4E /9瓦特/ GDUQdjZ27mrUWrYBgipgHnNvS8mOjdaNXU =”, “employee”=> {“empl_id”=>“”,“confirmation_date”=>“”, “designation_id”=>“”,“rep_head1_id”=>“”,“payment_mode”=>“”, “pf_number”=>“”,“bank_name”=>“”,“pt_applicable”=>“false”, “reg_date”=>“”,“employee_type_id”=>“”,“joined_date”=>“”, “rep_head2_id”=>“”,“pf_applicable”=>“false”, “bank_account_number”=>“”,“empl_email_id”=>“false”, “last_working_date”=>“”},“designation_level”=>“L-5b”, “user”=> {“username”=>“dsaf.adsfas”,“password”=>“[FILTERED]”}, “commit”=>“下一步”,“a”=>“user_management / edit_official / 31”}
编辑:包含表格
<% url = user_management_update_official_path(@employee) %>
<%= form_for(@employee, :url => url, :html => { :enctype => 'multipart/form-data'} ) do |f| %>
<div id="employee_details" class="employee_form_steps">
<%= render :partial => 'user_management/employees/official_information',
:locals => { :f => f} %>
</div>
<div class="btn_row">
<%= content_tag(:button, '< Back', :id => 'official_information_back', :class => 'grey') %>
<%= f.submit 'Next', :class => 'green', :style => 'margin:0px;padding:4px;width:50px;' %>
<%= content_tag(:button, 'Cancel', :class => 'cancel grey') %>
</div>
<% end %>
答案 0 :(得分:0)
错误必须在routes.rb
此文件中的规则是:首次匹配,首次投放。
尝试获取与"errors#index"
对应的行,并将其放在描述/user_management/edit_official/:id
答案 1 :(得分:0)
实际问题是用于表单的http
方法。在我指定form_for
的路线中,put
使用了POST
方法。将POST
更改为PUT
,一切正常。