Coder Social home page Coder Social logo

attached's People

Contributors

ksylvest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

attached's Issues

Unsupported STI Inheritence

For example:

class Attachment < ActiveRecord::Base
  has_attached :file, path: "attachments/:style/:identifier:extension"
end

class Image < Attachment
  has_attached :file, processor: :image
end

undefined method `attached'

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

NoMethodError (undefined method `file_identifier' for #<Document:0x27117a8>):

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.