Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 没有与固定图像的[GET]匹配的路由_Ruby On Rails_Ruby_Image_Routes_Paperclip - Fatal编程技术网

Ruby on rails 没有与固定图像的[GET]匹配的路由

Ruby on rails 没有与固定图像的[GET]匹配的路由,ruby-on-rails,ruby,image,routes,paperclip,Ruby On Rails,Ruby,Image,Routes,Paperclip,当当前用户单击pin时,如何将图像保存到当前用户 按钮: <%= simple_form_for(@inspiration) do |f| %> <%= f.hidden_field :image_file_name, value: inspiration.image_file_name %> <%= f.hidden_field :image_content_type, value: inspiration.image_content_typ

当前用户
单击pin时,如何将图像保存到
当前用户

按钮:

  <%= simple_form_for(@inspiration) do |f| %>
    <%= f.hidden_field :image_file_name, value: inspiration.image_file_name %>
    <%= f.hidden_field :image_content_type, value: inspiration.image_content_type %>
    <%= f.hidden_field :image_file_size, value: inspiration.image_file_size %>
    <%= button_tag(type: 'submit', class: "btn btn-primary") do %>
      <span class="glyphicon glyphicon-pushpin"></span>
    <% end %>
  <% end %>
对于给出错误的固定图像,
id
不同:
No route matches[GET]“/system/inspirations/images/000/002/medium/choose optimization.png”

工作图像具有
001

/system/inspirations/images/000/000/001/medium/choose optimization.png?1478840469

修复此问题的最佳方法是什么,这样我可以继续传递不同的ID,但使用相同的图像

控制器

@inspirations = @user.inspirations # Renders Images with Pin Overlayed
@inspiration = current_user.inspirations.build # For the Button

def create
  @inspiration = current_user.inspirations.build(inspiration_params)
  @inspiration.save
  respond_modal_with @inspiration
end

在您的模型中:

has_attached_file :image, url: '/system/inspirations/images/:style/:filename'

但是,完成此操作后,您必须重新创建您的第一个灵感,以便它使用新的URL插值。

您可以发布控制器操作的代码吗?@muradyusfov done!我认为您需要定义一个自定义插值。等一下,我试着写一个答案
has_attached_file :image, url: '/system/inspirations/images/:style/:filename'