在我的Rails應用程序中,我已獲得carrierwave gem上傳內容。現在我想fileformatscarrierwave白名單錯誤未顯示
的驗證,所以我一直在上傳添加了這個:
def extension_white_list
%w(jpg jpeg gif png)
end
當我試圖把它上傳不到風度上傳PDF格式的PDF,但沒有錯誤打印到屏幕上。什麼不見了?
我認爲頁面應該回去,所以用戶有機會選擇不同的文件?
感謝
UPDATE - 表格查看代碼:
<%= form_for(@channel, :html => {:multipart => true, :class => "form-horizontal", :role => "form"}, :method => :post, :url => url_for(controller: 'channels', action: 'edit', id: @channel.id)) do |f| %>
<div class="col-md-4">
<div class="form-group col-md-12">
<label><%= f.label :channelimage %></label>
<%= f.file_field :channelimage, :class => "form-control", :placeholder => :image%>
<br>
<% if @channel.channelimage.present? %>
<div clasS="thumbnail">
<img src="<%= @channel.channelimage %>" alt="<%= @channel.channelname %>"/>
</div>
<% end %>
</div>
</div>
UPDATE:控制器功能
#Speichert die geänderten Werte eines Channels
def edit
@user = User.find_by_id session[:user_id]
@knowledgeproviderList = @user.knowledgeprovider
@channel = Channel.find params[:id]
@channelList = Channel.where(knowledgeprovider_id: @knowledgeproviderList.pluck(:id))
if request.post?
@channel.update_attributes(channel_edit_params)
if @channel.save
flash[:notice] = t("flash.saved")
redirect_to action: :index
else
redirect_to action: :edit, :id => @channel.id
end
end
end
你可以發佈你在哪裏輸出錯誤的時刻 –
也許這就是問題... ...無處視圖代碼...不知道怎麼回事,在文檔是沒有提到如何 – Felix
我的東西已將視圖代碼添加到 – Felix