Created
October 25, 2008 15:20
-
-
Save grobie/19750 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Doc < File | |
| has_attachment :content_type => 'application/msword', | |
| :max_size => 2.megabytes, | |
| :storage => :file_system | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class File < ActiveRecord::Base | |
| belongs_to :invoice | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Invoice < ActiveRecord::Base | |
| has_one :pdf | |
| has_one :doc | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InvoicesController | |
| def new | |
| @invoice = Invoice.new | |
| @file = File.new | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Pdf < File | |
| has_attachment :content_type => 'application/pdf', | |
| :max_size => 2.megabytes, | |
| :storage => :file_system | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CreateFiles < ActiveRecord::Migration | |
| def self.up | |
| create_table :files do |t| | |
| t.string :type, :file_name, :content_type | |
| t.integer :size, :invoice_id | |
| t.timestamps | |
| end | |
| end | |
| def self.down | |
| drop_table :addresses | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment