我有一个视图,我可以创建,编辑房间,当我选择照片并点击更新按钮时,我可以为该房间选择照片我收到错误消息:
ActionController::RoutingError (No route matches [GET] "/images/localhost/photos/images/56f9/2fae/23fb/c028/d600/0003/original/large3.jpg"):
这里的班级模型:
class Room
include Mongoid::Document
validates :listing_name, length: {maximum: 50}, presence: true
field :home_type, type: String
field :room_type, type: String
embeds_many :photos
belongs_to :user
end
class Photo
include Mongoid::Document
include Mongoid::Paperclip
embedded_in :room, :inverse_of => :photos
has_mongoid_attached_file :image,
:styles => {
:original => ['1920x1680>', :jpg],
:small => ['100x100#', :jpg],
:medium => ['250x250', :jpg],
:large => ['500x500>', :jpg]
},
:convert_options => { :all => '-background white -flatten +matte' }
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
end
class RoomsController < ApplicationController
def create
@room = current_user.rooms.build(room_params)
if @room.save
if params[:images]
params[:images].each do |image|
@room.photos.create(image: image)
end
end
@photos = @room.photos
redirect_to edit_room_path (@room), notice: "Saved..."
else
render :new
end
end
end
这里路线
resources :rooms
resources :posts
resources :comments
resources :photos
resources :rooms do
resources :reservations, only: [:create]
end
get '/preload' => 'reservations#preload'
此处观看
<% if @photos %>
<div class="row">
<% @photos.each do |photo| %>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading preview">
<%= image_tag photo.image.url() %>
</div>
<div class="panel-body">
<span class="pull-right">
<%= link_to photo, remote: true, method: :delete, data: {confirm: "Are you sure?"} do %>
<i class="fa fa-times fa-lg"></i>
<% end %>
</span>
</div>
</div>
</div>
<% end %>
</div>
<% end %>
有人请帮帮我,最新消息是什么?错了我的源代码:-( ... ??