dear all
I followed http://clarkware.com/cgi/blosxom/2007/02/24 i installed ImageScience and FreeImage. whenever I create an entry it does not get to the database and it does not upload the file
I am not sure what is wrong in the code, especially it is mere copy
paste ![]()
I added this to config/environment.rb config.gem 'image_science'
config/route.rb map.resources :mugshots
this is the code
class Mugshot < ActiveRecord::Base has_attachment :content_type => :image, :storage => :file_system, :max_size => 500.kilobytes, :thumbnails => { :thumb => '100x100>' }, :processor => 'ImageScience'
validates_as_attachment end
class MugshotsController < ApplicationController def index @mugshots = Mugshot.find(:all) end def new @mugshot = Mugshot.new end
def create @mugshot = Mugshot.new(params[:mugshot]) if @mugshot.save flash[:notice] = 'Mugshot was successfully created.' redirect_to mugshot_url(@mugshot) else render :action => :new end end
end
new.html.erb
<%= error_messages_for :mugshot %>
<% form_for(:mugshot, :url => mugshots_path, :html => { :multipart => true }) do |f| -%> <p> <label for="mugshot">Upload A Mugshot:</label> <%= f.file_field :uploaded_data %> </p> <p> <%= submit_tag 'Create' %> </p> <% end -%>
index.html.erb
<h1>Most Wanted</h1> <% for mugshot in @mugshots -%> <%= link_to image_tag(mugshot.public_filename(:thumb)), mugshot.public_filename %> <% end -%>
this is what i get from the log
Processing MugshotsController#new (for 127.0.0.1 at 2008-08-15 18:43:24) [GET] Session ID: BAh7BzoMY3NyZl9pZCIlNjNjMGFiZGY4OGIxNzMzNTJlY2NkNWU0YmY5ZWMz ODMiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh c2h7AAY6CkB1c2VkewA=--a3b1e1c814f7d712aaf16820f4db2041b4a0d785 Parameters: {"action"=>"new", "controller"=>"mugshots"} SQL (0.000184) SET NAMES 'utf8' SQL (0.000098) SET SQL_AUTO_IS_NULL=0 Mugshot Columns (0.000911) SHOW FIELDS FROM `mugshots` Rendering mugshots/new Completed in 0.03245 (30 reqs/sec) | Rendering: 0.00226 (6%) | DB: 0.00119 (3%) | 200 OK [http://localhost/mugshots/new\]
Processing MugshotsController#index (for 127.0.0.1 at 2008-08-15 18:43:27) [POST] Session ID: BAh7BzoMY3NyZl9pZCIlNjNjMGFiZGY4OGIxNzMzNTJlY2NkNWU0YmY5ZWMz ODMiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh c2h7AAY6CkB1c2VkewA=--a3b1e1c814f7d712aaf16820f4db2041b4a0d785 Parameters: {"commit"=>"Create", "authenticity_token"=>"f4c278ba18f30630d063c45f4d5bb84000f7682c", "action"=>"index", "controller"=>"mugshots", "mugshot"=>{"uploaded_data"=>#<File:/tmp/CGI21597-1>}} Mugshot Load (0.001881) SELECT * FROM `mugshots` Rendering mugshots/index Completed in 0.01364 (73 reqs/sec) | Rendering: 0.00134 (9%) | DB: 0.00188 (13%) | 200 OK [http://localhost/mugshots\]
Processing MugshotsController#index (for 127.0.0.1 at 2008-08-15 18:44:44) [POST] Session ID: BAh7BzoMY3NyZl9pZCIlNjNjMGFiZGY4OGIxNzMzNTJlY2NkNWU0YmY5ZWMz ODMiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh c2h7AAY6CkB1c2VkewA=--a3b1e1c814f7d712aaf16820f4db2041b4a0d785 Parameters: {"commit"=>"Create", "authenticity_token"=>"f4c278ba18f30630d063c45f4d5bb84000f7682c", "action"=>"index", "controller"=>"mugshots", "mugshot"=>{"uploaded_data"=>#<File:/tmp/CGI21597-3>}} Mugshot Load (0.000139) SELECT * FROM `mugshots` Rendering mugshots/index Completed in 0.01159 (86 reqs/sec) | Rendering: 0.00081 (6%) | DB: 0.00014 (1%) | 200 OK [http://localhost/mugshots\]