Sử dụng Rails Admin với Dragonfly. Tuy nhiên, khi tôi đã tạo một bài đăng mới có tệp đính kèm được kết nối :ob
với con chuồn chuồn và muốn chỉnh sửa nó. Nó sais "Không có tập tin được chọn". Vì nó không nhận được rằng đã có một tập tin?Rails Admin Với Dragonfly - Chỉnh sửa. Không có tệp nào hiện diện
Trong rails_admin tôi đã thực hiện việc này.
edit do
field :name
field :information
field :ob, :dragonfly
field :document_categories
end
Dưới đây là mô hình của tôi:
class Document < ActiveRecord::Base
has_and_belongs_to_many :document_categories
after_commit :generate_versions, on: :create
dragonfly_accessor :ob
validates :name, :ob, presence: true
def generate_versions
DocumentWorker.perform_async(self.id)
end
def convertable_image?
unless self.try(:ob).nil?
self.try(:ob).mime_type.include?("image") || self.try(:ob).mime_type.include?("pdf")
else
return false
end
end
def respond_with_type
case self.try(:ob).mime_type.split("/")[1]
when "vnd.ms-powerpoint" , "vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.template"
"powerpoint"
when "application/vnd.ms-excel" , "vnd.openxmlformats-officedocument.spreadsheetml.sheet"
"excel"
when "application/msword" , "vnd.openxmlformats-officedocument.wordprocessingml.document"
"word"
else
self.try(:ob).mime_type.split("/")[1]
end
end
default_scope{order("name ASC")}
end
Dưới đây là sơ đồ của tôi:
create_table "documents", force: :cascade do |t|
t.string "name"
t.string "ob"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "ob_uid"
t.string "ob_name"
t.text "information"
end
Có điều gì khác mà tôi cần phải làm để cho nó để lấy các tập tin?
https://github.com/sferik/rails_admin
https://github.com/markevans/dragonfly
bạn có thể hiển thị các mô hình và sơ đồ có sử dụng Dragonfly và đây có phải là chế độ xem tùy chỉnh không? – SacWebDeveloper
@SacWebDeveloper đã hoàn tất! Không có nó không phải là một cái nhìn theo yêu cầu. – Philip
Bạn cũng có thể đăng 'biểu mẫu' có trong chế độ xem không? – sahil