Я застрял с очень простыми вещами здесь в моем приложении.
У меня есть форма, которую я хочу выполнить, используя coffeescript.
Мой контроллер / действие - это ProfilesController # edit_profile_photos
И мое мнение таково: /profile/edit/profile_photos.html.erb
<span class="file-upload">
<div class="progress" id='progress-bar' style='display:none;'>
<div class="progress-bar progress-bar-striped active" role="progressbar" style="width: 0%">
<span class="sr-only" id='progress-bar-text'></span>
</div>
</div>
<button type="button" class="btn btn-lg btn-outline-green trigger-file-upload">Upload a new photo</button>
<%= f.attachment_field :avatar, direct: true, presigned: true %>
</span>
Итак, я создал пользователей.кофейный файл с этим:
$(document).ready ->
alert "page has loaded!"
jQuery ->
$(document).on "upload:start", "form", (e) ->
$(this).find("input[type=submit]").attr "disabled", true
$("#progress-bar").slideDown('fast')
$(document).on "upload:progress", "form", (e) ->
detail = e.originalEvent.detail
percentComplete = Math.round(detail.loaded / detail.total * 100)
$('.progress-bar').width("#{percentComplete}%");
$("#progress-bar-text").text("#{percentComplete}% Complete")
$(document).on "upload:success", "form", (e) ->
$(this).find("input[type=submit]").removeAttr "disabled" unless $(this).find("input.uploading").length
$("#progress-bar").slideUp('fast')
Хорошо.Я не знаю, почему мой файл кофе не загружается.Должен ли он иметь такое же имя контроллера?(Profiles.coffee)?
Спасибо