Paperclip을 웹 앱에 통합하려고합니다. 문제는 업로드 버튼이 작동하지 않는다는 것입니다. 파일을 선택하고 제목 등을 입력 할 수 있지만 업로드시에 히트하면 아무 일도 일어나지 않습니다.레일 클립 클립 업로드 버튼이 작동하지 않습니다.
내가 클립 부착하지 않고, 다시
<%= form_for @video, url: videos_path, html: { multipart: true } do |form| %>
<%= form.file_field :image %>
<% end %>
업로드 버튼을 다시 작동하고 _form.html.erb 파일에서 제거 할 수 있지만.
이 문제를 해결하는 방법에 대한 아이디어가 있으십니까?
_form.html.erb 파일
<div class="container">
<%= form_for(@video) do |f| %>
<% if @video.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@video.errors.count, "error") %> prohibited this video from being saved:</h2>
<ul>
<% @video.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :jwPlayer %><br>
<%= f.text_field :jwPlayer %>
</div>
<div class="field">
<%= f.label :description %><br>
<%= f.text_area :description %>
</div>
<div class="field">
<%= f.label :title %><br>
<%= f.text_area :title %>
</div>
<%= form_for @video, url: videos_path, html: { multipart: true } do |form| %>
<%= form.file_field :image %>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
</div>
Video_controller
class VideosController < ApplicationController
before_action :set_video, only: [:show, :edit, :update, :destroy]
# GET /videos
# GET /videos.json
def index
@videos = Video.all
end
# GET /videos/1
# GET /videos/1.json
def show
end
# GET /videos/new
def new
@video = Video.new
end
# GET /videos/1/edit
def edit
end
# POST /videos
# POST /videos.json
def create
@video = Video.new(video_params)
respond_to do |format|
if @video.save
format.html { redirect_to @video, notice: 'Video was successfully created.' }
format.json { render :show, status: :created, location: @video }
else
format.html { render :new }
format.json { render json: @video.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /videos/1
# PATCH/PUT /videos/1.json
def update
respond_to do |format|
if @video.update(video_params)
format.html { redirect_to @video, notice: 'Video was successfully updated.' }
format.json { render :show, status: :ok, location: @video }
else
format.html { render :edit }
format.json { render json: @video.errors, status: :unprocessable_entity }
end
end
end
# DELETE /videos/1
# DELETE /videos/1.json
def destroy
@video.destroy
respond_to do |format|
format.html { redirect_to videos_url, notice: 'Video was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_video
@video = Video.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def video_params
params.require(:video).permit(:jwPlayer, :description, :title, :image)
end
end
Video.rb
class Video < ActiveRecord::Base
has_attached_file :image, styles: { medium: "300x300>", thumb: "100x100>" }
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
end
당신이 오류/로그를 게시 할 수 있습니까? –