Last active
December 5, 2018 15:09
-
-
Save staycreativedesign/a9e9452a2bdf331b3d2b5595150e4ba8 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
= f.fields_for :documents_attributes do |ff| | |
= ff.hidden_field :graphic, class: "upload-hidden" | |
Processing by Admin::LessonsController#create as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"I3NfaupPeavweIfWD3bxxXpev3+46prtirGNxx88Fs/FGWBXuVO8GFu4qpFYxJFVugxhEIpFpd9amPbOgYIffg==", "lesson"=>{"title"=>"lesson 1", "video_link"=>"lesson 1", "documents_attributes"=>{"graphic"=>""}, "description"=>""}, "uploading_image"=>"", "commit"=>"Create Lesson", "course_id"=>"foobar"} | |
Membership Load (0.3ms) SELECT "memberships".* FROM "memberships" WHERE "memberships"."id" = $1 LIMIT $2 [["id", 51], ["LIMIT", 1]] | |
Course Load (0.3ms) SELECT "courses".* FROM "courses" WHERE "courses"."slug" = $1 LIMIT $2 [["slug", "foobar"], ["LIMIT", 1]] | |
Completed 500 Internal Server Error in 11ms (ActiveRecord: 0.6ms) | |
TypeError (no implicit conversion of Symbol into Integer): | |
app/controllers/admin/lessons_controller.rb:18:in `create' | |
Using Shrine Gem |
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
# == Schema Information | |
# | |
# Table name: documents | |
# | |
# id :bigint(8) not null, primary key | |
# graphic_data :text | |
# documentable_type :string | |
# documentable_id :bigint(8) | |
# created_at :datetime not null | |
# updated_at :datetime not null | |
# | |
class Document < ApplicationRecord | |
belongs_to :documentable, polymorphic: true, optional: true | |
include FileUploader::Attachment.new(:graphic) | |
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 FileUploader < Shrine | |
plugin :activerecord | |
plugin :cached_attachment_data # for retaining the cached file across form redisplays | |
plugin :restore_cached_data # re-extract metadata when attaching a cached file | |
plugin :determine_mime_type | |
plugin :remove_attachment | |
plugin :delete_raw | |
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
def lesson_params | |
params.require(:lesson).permit(:video_link, :title, :slug, :description, documents_attributes: [:graphic]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment