ksylvest / attached Goto Github PK
View Code? Open in Web Editor NEWA file attachment tool that lets users upload to the cloud
Home Page: http://ksylvest.github.com/attached/
License: MIT License
A file attachment tool that lets users upload to the cloud
Home Page: http://ksylvest.github.com/attached/
License: MIT License
Hello, I have this error when migrating on rails 3.1.1
Run:
rake db:migrate
undefined method `attached' for #ActiveRecord::ConnectionAdapters::TableDefinition:0xb6c97cf8
My code is:
class CreateVideos < ActiveRecord::Migration
def self.up
create_table :videos do |t|
t.string :title
t.text :description
t.attached :video_hd
t.timestamps
end
end
def self.down
drop_table :videos
end
end
For example:
class Attachment < ActiveRecord::Base
has_attached :file, path: "attachments/:style/:identifier:extension"
end
class Image < Attachment
has_attached :file, processor: :image
end
Hi,
I get NoMethodError (undefined method 'file_identifier' for #<Document:0x27117a8>)
when I try to save a form with attachement.
new.haml
= simple_form_for @document, :remote => true, :novalidate => true do |form|
%p#errors{:style => 'display:none'}
%p
Title
= form.text_field :title, :required => true
%p
Description
= form.text_field :description, :required => true
%p
File to upload
= form.file_field :file, id: 'file'
.clear
.action_bar
%input.button.blue.small{type: "submit", value: "Submit"}
%a.button.red.small
%span.glyph.cross
Annuler
document.rb (model)
class Document < ActiveRecord::Base
attr_accessible :description, :file, :title
validates :title, :description, presence: true
validates_attached_presence :file
has_attached :file
end
schema
create_table "documents", :force => true do |t|
t.string "title"
t.text "description"
t.integer "company_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "file_file_name"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
end
POST REQUEST
Started POST "/documents" for 127.0.0.1 at 2012-07-31 15:09:50 +0200
Processing by DocumentsController#create as JS
Parameters: {"utf8"=>"V", "authenticity_token"=>"DVrcEoFETW+iohGHFa1GdvRPjnmGbcaGpiWhLnZbXOc=", "document"=>{"title"=
"dd", "description"=>"dd"}}
←[1m←[35mUser Load (0.0ms)←[0m SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 3]]
←[1m←[36mCompany Load (0.0ms)←[0m ←[1mSELECT "companies".* FROM "companies" WHERE "companies"."id" = 3 LIMIT 1←[0m
Completed 500 Internal Server Error in 4ms
NoMethodError (undefined method `file_identifier' for #<Document:0x27117a8>):
app/controllers/documents_controller.rb:30:in `create'
Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/middleware/templates/rescues/_trace
erb (4.0ms)
Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/middleware/templates/rescues/_reque
t_and_response.erb (2.0ms)
Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/middleware/templates/rescues/diagno
tics.erb within rescues/layout (36.0ms)
documents_controller
def create
....
....
@document =Document.new(params[:document])
if @document.valid?
@document.save
end
....
....
end
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.