gpt4 book ai didi

ruby-on-rails - ActionController::RoutingError (No route matches [GET] "/system/pictures/assets/small/IMG_-_WIN_20141206_09

转载 作者:行者123 更新时间:2023-12-04 06:11:54 27 4
gpt4 key购买 nike

我正在尝试在我的 Rails 应用程序中上传图片,但它给了我

error:- (No route matches [GET] "/system/pictures/assets/small/Image_-_WIN_20141206_09.

我不知道我错在哪里。我尝试提供 url、路径,我还上传了 rails Logo 并移动到 app/assets/images

$ curl -O http://rubyonrails.org/image/rails.png


$ mv rails.png app/assets/images/

我的 git 存储库位于:https://github.com/sarahgupta022/book.git


这是我的picture.rb


class Picture < ActiveRecord::Base

belongs_to :album

belongs_to :user

attr_accessible :caption, :description, :asset

has_attached_file :asset, style: {
large: "800x800>", medium: "300x200>", small: "260x180>", thumb: "80x80#"
} , :default_url => "/app/assets/images/small/rails.png"


validates_attachment_file_name :asset, :matches => [/png\Z/, /jpe?g\Z/, /gif\Z/]
validates :asset, attachment_presence: true

def to_s

caption? ? caption : "Picture"
end
end

这是我的views/pictures/index.html.erb


<% @pictures.each do |picture| %>
<li>
<div class="thumbnail">
<%= link_to image_tag(picture.asset.url(:small)), album_picture_path(@user, @album, picture) %><br /><br />
<div class="caption">
<% if picture.caption? %><%= picture.caption %><br /><br /><% end %>

<%= link_to 'View full size', album_picture_path(@user, @album, picture) %>

<% if can_edit_picture?(picture) %>
<%= link_to "Edit", edit_album_picture_path(@album, picture) %>
<%= link_to "Delete", album_picture_path(@album, picture), method: :delete, data: { confirm: "Are you sure?" } %>
<% end %>
</div>
</div>
</li>

非常感谢任何帮助。谢谢!

最佳答案

你必须改变这个:

:default_url => "/app/assets/images/small/rails.png"

为此:

:default_url => "images/:style/rails.png"

关于ruby-on-rails - ActionController::RoutingError (No route matches [GET] "/system/pictures/assets/small/IMG_-_WIN_20141206_09,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31083605/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com