2016-06-20 7 views
0

Ich habe mir die anderen Fragen über fehlende Vorlagen angesehen, aber ihre Fehler scheinen hier nicht der Fall zu sein. z.B. Ich habe keine remote: true in meiner Form.Update nicht umleiten zu zeigen - fehlende Vorlage

Ich habe ein Formular, um eine Inspektion zu aktualisieren:

<%= 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 %> 

Hier ist der Controller:

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 

So sollte es in die Show Ansicht umleiten (was natürlich existiert).

Stattdessen versucht es Inspektionen/Update zu finden und fehlschlägt:

Fehlende Vorlage Inspektionen/update, application/Update mit {: locale => [: en]: Formate => [: html ],: variants => [],: handlers => [: erb, : builder,: roh,: rubin,: kaffee,: jbuilder]}.

Bearbeiten- Hier ist meine 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

Geleia, können Sie bitte Ihre routes.rb teilen? – Alex

+0

@David Natürlich. Ich habe es dem ursprünglichen Beitrag hinzugefügt. – GeleiaDeMocoto

Antwort

1

Dieses:

format.html { redirect_to @inspection, 
notice: 'Inspection was successfully Updated. Images are being Processed in the background. ~1 minute per 50 files' } and return 

format.html { redirect_to @inspection, 
notice: 'Inspection was successfully Updated. Images are being Processed in the background. ~1 minute per 50 files' and return } 

Beachten Sie die Position der Rückkehr sein sollte. Eigentlich ist die Rückgabe innerhalb des Blocks unnötig, Sie können es komplett weglassen.

Verwandte Themen