我已经看过关于丢失模板的其他问题,但他们的错误似乎并非如此。例如我没有 remote:true 在我的表单中。
我有一张表格来更新检验:
<%= simple_form_for @inspection , :html => { multipart: true } do |f| %>
<%= f.error_notification %>
<%= hidden_field_tag :building_id, @building.id %>
<div class="form-inputs">
<div class="form-group select optional inspection_building">
<label class="select optional control-label" for="inspection_building_id">Building: </label>
<%= @building.name %>
</div>
<div class="form-group select optional inspection_building">
<label class="select optional control-label" for="inspection_building_id">Bot: </label>
<%= Inspection::BOTS[0] %>
</div>
<%= f.input :inspection_label %>
<%= f.input :notes %>
<div class="controls form-group integer required">
<div>
<%= f.input :capture_date, as: :date, html5: true, label: "Capture Date of Inspection Images" %>
</div>
</div>
<% if true #if @inspection.new_record? #only show for new inspections %>
<%= render 'attach_image_meta_files' %>
<br>
<div class="controls form-group integer required">
<label class="integer required control-label" for="layout_type">What Excel file Layout, Filip?</label>
<div>
<%= select_tag :layout_type,
options_for_select(%w[New Old]) %>
</div>
</div>
<div class="controls form-group integer required">
<label class="integer required control-label" for="image_file_prefex">Image File Prefex? (this combined the the Excel file Image Number needs to match the image file names uploaded)</label>
<div>
<%= text_field_tag :image_file_prefex, 'DSC_', class: 'required form-control' %>
</div>
</div>
<div class="controls form-group integer required">
<label class="integer required control-label" for="first_row_of_data">First Row of Data?</label>
<div>
<%= number_field_tag :first_row_of_data, 3, in: 1..10, class: 'numeric integer required form-control' %>
</div>
</div>
<div class="controls form-group integer required">
<label class="integer required control-label" for="top_floor">What is the Top Floor of the Building (what floor number do you want the Roof to be)?</label>
<div>
<%= number_field_tag :top_floor, 1, in: 1..100, class: 'numeric integer required form-control' %>
</div>
</div>
<% end %>
</div>
<br>
<span id="loading-msg" class="text-center display_loading" style="position: absolute; top: 200px; left: 0; bottom: 0; right: 0; margin: auto; color:blue; display:none">
<%= image_tag "ajax-loader.gif", alt: "loading", id: "loading_image", class: "center-block" %>Uploading Images and Processing. This will take a while!
</span>
<script>
$(".display_loading").on("click", function() {
$('#loading-msg').show();
})
</script>
<div class="form-actions">
<% if @inspection.new_record? #only show for new inspections %>
<%= f.button :button, class: 'btn btn-success display_loading' do %>
<span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span> Upload and Process Inspection Files
<% end %>
<% else %>
<%= f.button :submit, class: 'btn btn-success' %>
<% end %>
</div>
<% end %>
这是控制器:
def update
respond_to do |format|
if @inspection.update(inspection_params)
Thread.new do
process_image_and_excel_metadata_files
end
format.html { redirect_to @inspection,
notice: 'Inspection was successfully Updated. Images are being Processed in the background. ~1 minute per 50 files' } and return
else
format.html { render :edit }
end
end
end
所以它应该重定向到show视图(当然存在)。
相反,它试图找到检查/更新并失败:
缺少模板检查/更新,应用程序/更新 {:locale =&gt; [:en] ,: formats =&gt; [:html],:variants =&gt; [],:handlers =&gt; [:erb, :builder,:raw,:ruby,:coffee,:jbuilder]}。
编辑 - 这是我的routes.rb:
RailsApp::Application.routes.draw do
resources :issues # later remove this
resources :issue_types
resources :inspection_images
resources :buildings do
resources :elevations
resources :user_buildings
end
resources :importer
resources :inspections do
get 'apply'
resources :image_reviews, only: :index
resources :issue_reviews, only: :index
end
resources :image_reviews, only: [ :show, :edit, :update] do
resources :issues
get 'print_issues'
post 'print_issues'
end
get 'inspections/:inspection_id/image_reviews(/:elevation_id)', to: 'image_reviews#index'
get 'inspections/:inspection_id/reorder/:drop_id', to: 'image_reviews#reorder', as: 'drop_reorder'
# authenticated :user.admin do
# root :to => "base#index"
# end
root "buildings#index"
get "user_buildings/:building_id/add_to_building" => 'user_buildings#add_to_building', :as => :add_to_building
namespace :admin do
root "base#index"
resources :users
end
devise_for :users
end
答案 0 :(得分:1)
此:
ação => açao
frações => fraçoes
应该是
format.html { redirect_to @inspection,
notice: 'Inspection was successfully Updated. Images are being Processed in the background. ~1 minute per 50 files' } and return
注意返回的位置。实际上在块内部不需要返回,你可以完全不用它。