Использование Rails Admin с Dragonfly. Однако, когда я создал новую запись с прикрепленным соединением :ob
к dragonfly и хочу ее отредактировать. Это sais «Файл не выбран». Как он не понимает, что уже есть файл?Rails Admin С Dragonfly - Редактировать. Нет файла
В моем rails_admin я сделал это.
edit do
field :name
field :information
field :ob, :dragonfly
field :document_categories
end
Вот моя модель:
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
Вот моя схема:
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
Есть ли что-нибудь еще, что мне нужно сделать для того, чтобы забрать файл?
https://github.com/sferik/rails_admin
https://github.com/markevans/dragonfly
Не могли бы вы показать модель и схему, которая использует Стрекоза и это пользовательский вид? – SacWebDeveloper
@SacWebDeveloper сделано! Нет, это не точка зрения. – Philip
Можете ли вы также опубликовать представленную форму? – sahil