So I changed my implentatio so that its set up as so:
The edit view:
<% form_for(@club, :html=>{:multipart=>true}) do |f| %>
<%= f.error_messages %>
<p><%= f.file_field :logo_bigg %></p>
<p>
<%= f.label :phone %><br />
<%= f.text_field :phone %>
</p>
<p>
<%= f.label :shortdesc %><br />
<%= f.text_area :shortdesc %>
</p>
</div>
<br class="clears"/>
<p class="submit_button">
<%= f.submit 'Create' %>
</p>
<% end %>
The clubs_controller:
def update
@club = Club.find(params[:id])
#if params[:club][:logo_big] && params[:club][:logo_big].size > 0
# @club.logo_big = params[:club][:logo_big].read
# end
# @club.save
respond_to do |format|
if @club.update_attributes(params[:club])
flash[:notice] = 'Club was successfully updated.'
format.html { redirect_to(@club) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @club.errors, :status
=> :unprocessable_entity }
end
end
end
def image
data = Club.find(params[:id]).data
send_data data, :disposition => 'inline'
end
The club model:
class Club < ActiveRecord::Base
include Magick
belongs_to :admin
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
The issue is that it works but my rails app freezes for like 30
seconds and I get a loud beeping from my console. When its done all I
see if what looks like binary string data for the logging of the last
few events.
--
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.