Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Attachment < ActiveRecord::Base
  validates_presense_of :title

  has_attached_file :image,
                    :styles => {:default => '720x720',
                                :thumb => '80x80',
                                :tiny => '40x40'}

  has_attached_file :video

end

class AttachmentsController < ApplicationController
  def create
    @attachment = Attachment.new(params[:attachment])

    respond_to do |format|
      if @attachment.save
        flash[:message] = 'ok'
        format.html { render :action => "index" }
        format.xml { render :xml => @attachment, :status => :created }
      else
        flash[:message] = 'error'
        format.html { render :action => "new" }
        format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }
      end
    end
  end
end