[Ror-es] ajax y rmagick

Davicín .. ruby-forum-incoming at andreas-s.net
Mon Nov 5 11:00:48 GMT 2007


Hola

Estoy intentando subir imágenes a traves de rmagick y ajax y no consigo
q funcione. Sin ajax funciona correctamente.

rhtml
---------
<% form_remote_for :photo, :update => "main_content", :url =>
{:controller =>        "photos", :action => "create", :tID =>
params[:tID] },
   :html => { :multipart => true } do |form| %>

   <input id="establishment_photo_establishment_id" name="e_photo[e_id]"
         type="hidden" value="1"/>
   <input id="logo" name="logo" type="hidden" value="logo"/>
   <tr>
  <td width="165" align="right">
            <img src="../images/txtlogo.gif">
        </td>
  <td nowrap>
      <div class="fileinputs">
    <input id="e_photo_uploaded_data" name="e_photo[uploaded_data]"
type="file" class="file" onChange="cambio()" size="15"/>
    <div class="fakefile">
          <input id="etiqueta" size="15"/>
      <img src="../images/buscar.gif" class="imagenbt"/>
    </div>
      </div>
  </td>
   </tr>
   <tr>
  <td height="20">&nbsp;</td>
  <td class="okLogo" valign="top">
     <%= image_submit_tag ("../images/aceptar.gif") %>
  </td>
   </tr>
<% end -%>

modelo
---------

class EstablishmentPhoto < ActiveRecord::Base
    has_attachment :content_type => :image,
    :storage => :file_system,
    :size => 0.bytes..2.megabytes,
    :resize_to => '640x480>',
    :path_prefix => "public",
    :thumbnails => { :thumb => '100x100' },
     :processor => :Rmagick

    validates_as_attachment
end

controller
-------------
      @e_photo = EstablishmentPhoto.new(params[:e_photo])
      if @e_photo.save
    flash[:errorlogo] = 'Su logo se ha subido correctamente.'
          cerrar
      else
          flash[:errorlogo] = 'ERROR.'
    render :action => 'list'
      end

Log
-----
undefined method `content_type' for "c:\\PC030031.JPG":String

En la base de datos tiene definido un campo como como varchar(100). Y
sin el ajax me ha estado funcionando sin problemas...

Alguien sabe pq puede ser?? Me estoy volviendo loco

Muchas gracias
-- 
Posted via http://www.ruby-forum.com/.


More information about the Ror-es mailing list