使用回形针插件通过get方法无法通过文件系统找到图像路径
经过很大的困难,我想我终于能够找到适合我项目配置的回形针 git 提交,即 Ruby 1.8.7 和 Rails 2.0.2。
在将回形针集成到我的项目中之前,我正在尝试实现 POC。 POC 基本上是在每个帖子旁边都有适当的图像来实现。它似乎很有效,只是当它尝试获取图像时,它当前显示路由错误。我能够在数据库中看到适当的反射,显示图像已与帖子消息一起插入。实际上,我在 Rails 应用程序中可以看到正在存储的图像.. 根据回形针使用的默认 url 将图像存储在文件系统中。
但我无法理解为什么它无法使用相同的 url 来获取图像并显示相同的图像。我基本上已经使用rails脚手架实现了这个POC,并做了一些适当的更改。
路由错误谈到使用 get 方法,我无法理解 get 方法在获取图像中起什么作用,我的控制器中没有任何此类方法。 在这种情况下,有些东西似乎很可疑..请告诉我同样的图像应该如何获取和显示..如果我在某些地方做错了..请同样纠正我..
我会喜欢添加...在我的应用程序的根目录中创建一个照片目录,其中有一个目录,每次添加带有适当图像上传的新帖子时都会创建一个目录。该目录名称由 id 组成,唯一标识其中的每个图像。实际的目录结构是这样的:-
rail_app_directory/photo/id_number/orginal/photo_filename.appropriate_file_format
更直接的例如上面发布的一般结构:- post_with_image/photo/1/original/sunset.jpeg
请在下面找到控制器的代码,以防万一:-
class PostsController < ApplicationController
# GET /posts
# GET /posts.xml
def index
@posts = Post.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
end
end
# GET /posts/1
# GET /posts/1.xml
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @post }
end
end
# GET /posts/new
# GET /posts/new.xml
def new
@post = Post.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post }
end
end
# GET /posts/1/edit
def edit
@post = Post.find(params[:id])
end
# POST /posts
# POST /posts.xml
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
flash[:notice] = 'Post was successfully created.'
format.html { redirect_to(@post) }
format.xml { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
# PUT /posts/1
# PUT /posts/1.xml
def update
@post = Post.find(params[:id])
respond_to do |format|
if @post.update_attributes(params[:post])
flash[:notice] = 'Post was successfully updated.'
format.html { redirect_to(@post) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /posts/1
# DELETE /posts/1.xml
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to(posts_url) }
format.xml { head :ok }
end
end
end
请找到我的 index.html.erb 文件的代码:-
<h1>Listing posts</h1>
<table>
<tr>
<th>Message</th>
</tr><br/>
</table>
<% for post in @posts %>
<%= image_tag post.photo.url %>
<table>
<tr><td><%=h post.message %></td></tr>
<tr><td><%= link_to 'Show', post %></td>
<td><%= link_to 'Edit', edit_post_path(post) %></td>
<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td></tr>
</table>
<br/> <hr/>
<% end %>
<br />
<%= link_to 'New post', new_post_path %>
这就是我所做的 tail -f log/development.log
ActionController::RoutingError (No route matches "/photo/4/original/ruby-on-rails.jpg" with {:method=>:get}):
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1441:in `recognize_path'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:281
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/server.rb:39
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
Rendering /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/templates/rescues/layout.erb (not_found)
Processing ApplicationController#index (for 127.0.0.1 at 2011-05-19 19:12:01) [GET]
Session ID: BAh7ByIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7ADoMY3NyZl9pZCIlZWVhYzk4NzczZDNjZDI4ZmY0%0ANzQ0NTU0NGU2YWJkMjk%3D--b8294cd9465ee6ac96f69b34362e3044138f3ee2
Parameters: {}
ActionController::RoutingError (No route matches "/photo/5/original/Water%20lilies.jpg" with {:method=>:get}):
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1441:in `recognize_path'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:281
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/server.rb:39
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
Rendering /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/templates/rescues/layout.erb (not_found)
^C** INT signal received.
Exiting
mohnish@mohnish-desktop:~/UP/pocs_tried_for_use/post_with_image$
[问题已编辑]
请找到模型post.rb的代码:-
class Post < ActiveRecord::Base
#require 'paperclip'
has_attached_file :photo
end
我的routes.rb文件看起来像这样:-
ActionController::Routing::Routes.draw do |map|
map.resources :posts
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
map.root :controller => "posts"
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
我不确定我哪里出了问题,请帮助我同样的..
非常感谢您的帮助...
with great difficulty , I guess I have finally been able to find the appropriate git commit of paperclip which would suit my project's config which is Ruby 1.8.7 and rails 2.0.2.
I am trying to implement a POC before I integrate paperclip in my project. The POC is basically implementing each post with an appropriate image beside it. It seems to pretty much work, its just that It currently showing routing errors when it is trying to fetch the image. I am able to see appropriate reflections in the DB showing that the image has been inserted with the post message. I actually in my Rails app can see the images being stored.. as per the default url used by paperclip to store the images in the file system.
But I am unable to understand why is it unable to use the same url to fetch back the image and display the same. I have basically implemented this POC using rails scaffold and made some appropriate changes.
The routing error talks about using the get method, I am unable to understand what role does get method play in fetching the image, I don't have any such method in my controller..
Something seems to be fishy wrt this scenario.. please enlighten me on the same on how exactly is the image supposed to be fetched and displayed.. if I am doing it wrong some where.. kindly correct me on the same..
I would like to add... a photos directory is created in my app's root directory and within that there is a directory which gets created every time a new post is added with an appropriate image upload. This directory name is coined with the an id, uniquely identifying each image within it. The actual directory structure is like this:-
rail_app_directory/photo/id_number/orginal/photo_filename.appropriate_file_format
A more direct e.g. to the general structure posted above:- post_with_image/photo/1/original/sunset.jpeg
Please find code for controller below just in case:-
class PostsController < ApplicationController
# GET /posts
# GET /posts.xml
def index
@posts = Post.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
end
end
# GET /posts/1
# GET /posts/1.xml
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @post }
end
end
# GET /posts/new
# GET /posts/new.xml
def new
@post = Post.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post }
end
end
# GET /posts/1/edit
def edit
@post = Post.find(params[:id])
end
# POST /posts
# POST /posts.xml
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
flash[:notice] = 'Post was successfully created.'
format.html { redirect_to(@post) }
format.xml { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
# PUT /posts/1
# PUT /posts/1.xml
def update
@post = Post.find(params[:id])
respond_to do |format|
if @post.update_attributes(params[:post])
flash[:notice] = 'Post was successfully updated.'
format.html { redirect_to(@post) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /posts/1
# DELETE /posts/1.xml
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to(posts_url) }
format.xml { head :ok }
end
end
end
Please find the code for my index.html.erb file:-
<h1>Listing posts</h1>
<table>
<tr>
<th>Message</th>
</tr><br/>
</table>
<% for post in @posts %>
<%= image_tag post.photo.url %>
<table>
<tr><td><%=h post.message %></td></tr>
<tr><td><%= link_to 'Show', post %></td>
<td><%= link_to 'Edit', edit_post_path(post) %></td>
<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td></tr>
</table>
<br/> <hr/>
<% end %>
<br />
<%= link_to 'New post', new_post_path %>
This is what I get doing a tail -f log/development.log
ActionController::RoutingError (No route matches "/photo/4/original/ruby-on-rails.jpg" with {:method=>:get}):
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1441:in `recognize_path'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:281
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/server.rb:39
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
Rendering /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/templates/rescues/layout.erb (not_found)
Processing ApplicationController#index (for 127.0.0.1 at 2011-05-19 19:12:01) [GET]
Session ID: BAh7ByIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7ADoMY3NyZl9pZCIlZWVhYzk4NzczZDNjZDI4ZmY0%0ANzQ0NTU0NGU2YWJkMjk%3D--b8294cd9465ee6ac96f69b34362e3044138f3ee2
Parameters: {}
ActionController::RoutingError (No route matches "/photo/5/original/Water%20lilies.jpg" with {:method=>:get}):
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1441:in `recognize_path'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:281
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/server.rb:39
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
Rendering /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/templates/rescues/layout.erb (not_found)
^C** INT signal received.
Exiting
mohnish@mohnish-desktop:~/UP/pocs_tried_for_use/post_with_image$
[QUESTION EDITED]
Please find the code for the model post.rb:-
class Post < ActiveRecord::Base
#require 'paperclip'
has_attached_file :photo
end
My routes.rb files looks like this:-
ActionController::Routing::Routes.draw do |map|
map.resources :posts
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
map.root :controller => "posts"
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
I am not sure where I am going wrong, Kindly help me with the same..
Thanks a lot for your help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是为了形式化问题评论中的答案:
您需要确保
/photo/4/original/ruby-on-rails.jpg
存在于您的public
文件夹下,因为默认情况下 Paperclip 应在此处存储其所有附件。Just to formalize the answer from the comments on the question:
You need to make sure
/photo/4/original/ruby-on-rails.jpg
exists under yourpublic
folder, as that's where Paperclip should be storing all of its attachments by default.