Rmagick wouldn't load on server for windows


#1

In windows, i’m trying to load rmagick for my app so i put

require ‘RMagick’

in environment.rb but the server wouldn’t start and it gives me this
error:

C:/ruby/lib/ruby/gems/1.8/gems/rmagick-2.6.0-x86-mswin32/ext/RMagick2.so
(LoadError)
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
require' from C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:inrequire’
from
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in
new_constants_in' from C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:inrequire’
from
C:/ruby/lib/ruby/gems/1.8/gems/rmagick-2.6.0-x86-mswin32/lib/RMagick.rb:11
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
gem_original_require' from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:inrequire’
from
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in
require' ... 18 levels... from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from ./script/server:3
from -e:4:in `load’
from -e:4

the file is there but it won’t load…any advice? ^_^!


#2

Was RMagick2.so built under windows?

On Oct 28, 9:23 am, Richard Y. removed_email_address@domain.invalid


#3

yes i’m running on windows at the moment.

well i got the rmagick to load and put the

required “Rmagick” in the environment.rb

but when i try to post something with image it rolls back and does not
post. i followed the guide from the advanced rails recipes and just
changed the names around but bleh.

the view:

<% form_for(@item, :html => { :multipart => true }) do |f| %>
<%= error_messages_for :item, :image %>

<%= f.label :title %>
<%= f.text_field :title %>

<%= f.label :description %>
<%= f.text_area :description %>

<%= label :item, :image %> <%= file_field_tag :image_file %> We accept JPEG, GIF, or PNG files up to 500 KB.

<%= f.label :price %>
<%= f.text_field :price %>

<%= f.submit "Create" %>

<% end %>

controller

def new
@item = Item.new

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml => @item }
end

end

GET /items/1/edit

def edit
@item = Item.find(params[:id])
end

POST /items

POST /items.xml

def create
@item = Item.new(params[:item])
@image = Image.new(:uploaded_data => params[:image_file])

@service = ItemService.new(@item, @image)

respond_to do |format|
  if @service.save
    flash[:notice] = 'Item was successfully created.'
    format.html { redirect_to(@item) }
    format.xml  { render :xml => @item,
                         :status => :created,
                         :location => @item }
  else
    format.html { render :action => "new" }
    format.xml  { render :xml => @item.errors,
                         :status => :unprocessable_entity }
  end
end

items_helper.rb

module ItemsHelper

def image_for(item, size = :medium)
if item.image
image_image = item.image.public_filename(size)
link_to image_tag(image_image), item.image.public_filename
else
image_tag(“blank-image-#{size}.png” )
end
end

end

item_service.rb

class ItemService

attr_reader :item, :image

def initialize(item, image)
@item = item
@image = image
end

def save
return false unless valid?
begin
Image.transaction do
if @image.new_record?
@item.image.destroy if @item.cover
@image.item = @item
@image.save!
end
@item.save!
true
end
rescue
false
end
end

def valid?
@item.valid? && @image.valid?
end

def update_attributes(item_attributes, image_file)
@item.attributes = item_attributes
unless image_file.blank?
@image = Image.new(:uploaded_data => image_file)
end
save
end

end

development.log

Processing ItemsController#create (for 127.0.0.1 at 2008-10-28 22:08:46)
[POST]
Session ID:
BAh7BzoMY3NyZl9pZCIlMDc3Y2M3ZGVjN2U5OWFhMGY5ZDUzMTQ1ZTRlYTc1
ZGEiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh
c2h7AAY6CkB1c2VkewA=–4332f39dc3fdbc9fc0d4d317ca2c57f1481d87df
Parameters:
{“image_file”=>#<File:C:/Users/HYUKYO~1/AppData/Local/Temp/CGI6348-3>,
“commit”=>“Create”,
“authenticity_token”=>“e798b2552991572d78d139f4268655e69369ee32”,
“action”=>“create”, “controller”=>“items”, “item”=>{“title”=>“adf”,
“price”=>“23”, “description”=>“asdfasdf”}}
e[4;35;1mItem Columns (0.004000)e[0m e[0mSHOW FIELDS FROM
itemse[0m
e[4;36;1mImage Columns (0.004000)e[0m e[0;1mSHOW FIELDS FROM
imagese[0m
e[4;35;1mSQL (0.001000)e[0m e[0mBEGINe[0m
e[4;36;1mSQL (0.000000)e[0m e[0;1mROLLBACKe[0m
Rendering template within layouts/items
Rendering items/new
Completed in 0.23000 (4 reqs/sec) | Rendering: 0.00400 (1%) | DB:
0.00900 (3%) | 200 OK [http://localhost/items]