Ive got the following setup:
uploads_controller.rb:
class UploadsController < ApplicationController before_action :set_upload, only: [:show, :edit, :update, :destroy]
Then I have route.rb containing these lines:
match 'uploads/refresh_table', to: 'uploads#refresh_table', via: :get resources :uploads
uploads.js.coffee:
$(document).ready ->
Views / Adds / index.html.erb
<table class="table table-striped"> <thead> <tr> <th>File name</th> <th>Upload Date, Time</th> <th>File Type</th> <th>Program Dates in file</th> <th>Total Rows</th> <th>Rows read</th> <th>Completed</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> <%= render (@uploads)%> <%# partial _upload.html.erb %> </tbody> </div> </table>
partial views / uploads / _upload.html.erb
<tr id= "uploads_table_rows"> <td> <%= upload.sourcedata_file_name%></td> <% path_arr = upload.f_path.split("\/")%> <td><%= path_arr[-3..-2].join(", ").gsub!("_", "\:")%></td> <td> <%= upload.sourcedata_content_type%></td> <td> <%= upload.date_ranges.pluck(:date_range).join(", ")%> <td> <%= upload.total_rows%></td> <td> <%= upload.rows_completed%></td> <td> <%= number_to_percentage(upload.percentage_complete, :precision => 0)%></td> </td> <%if (upload.status == 0 ) %> <td>Error </td> <%elsif (upload.status == 1 ) %> <td>File saved on server</td> <%elsif (upload.status == 3 ) %> <td>File is being parsed </td> <%elsif (upload.status == 2 ) %> <td>File data already in Database </td> <%else%> <td>File doesn't exist on Server</td> <%end%> <td><%= render 'button', :upload => upload%></td> </tr>
then I have views / uploads / refresh_table.js.erb
$('#uploads_table_rows').html("<%=escape_javascript(render(@uploads)) %>");
When i turn to
some_url/uploads/refresh_table
I get an error in the browser:
ActionController::UnknownFormat Request parameters {"controller"=>"uploads", "action"=>"refresh_table"}
server output:
Started GET "/uploads/refresh_table" for 127.0.0.1 at 2014-01-02 21:10:26 -0500 Processing by UploadsController
I tried to debug this and do this work for 2 days with different approaches, but to no avail. Finally, I know that routing works here, but for some reason the javascript view is now not displayed.
Can someone please. Thanks