I removed my previous posts to keep this simple. I have an
implementation as so:
club Model
class Club < ActiveRecord::Base
# include Magick
set_primary_key "club_id"
def logo_bigg=(input_data)
self.filename = input_data.original_filename
self.content_type = input_data.content_type.chomp
self.logo_big = input_data.read
end
def self.find_clubs
find(:all, :order => "name", :limit => 10)
end
def self.find_clubs2
find(:all, :order => "name", :limit => 5)
end
end
clubs Controller:
def updateIMG
@club = Club.find(params[:id])
if params[:club][:logo_big] && params[:club][:logo_big].size > 0
@club.data = params[:club][:logo_big].read
end
@club.save
if @club.update_attributes(params[:club])
redirect_to :action => 'index'
else
render :action => 'edit'
end
end
edit club View:
<% form_for @club, :url => { :action =>
'updateIMG', :id=>@club}, :html=>{:multipart=>true} do |f| %>
<p> <%= f.error_messages %> </p>
<p class="edit_image"><%= image_tag url_for(:controller =>
"clubs", :action => "show_pic_big", :id => @club.club_id) %></p>
<div style=" width:200px;">
<p> <%= f.file_field :logo_bigg %></p>
<p> <%= f.submit 'Update' %> </p>
</div><br class="clears"/>
<% end %>
This spits out an output that i will show in the following post from
my development log.
On Aug 8, 4:48 pm, Xenio <[email protected]> wrote:
> I have a DB that is already populated with data. There is a table
> called clubs that has an logo_big field set up as a blob. I have
> successfully used send_data to display the jpg pictures as I need them
> in the views. I just need to setup the edit/new view to enable me to
> upload the files.
>
> I tried paperclip but that requires changing the schema of the
> database which is not really an option for me.
>
> I am looking for a simple implementation to change the image file.
>
> I have been hunting around the "to_blob" and "send_data" parameters
> with no luck. Any help with this?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.