Skip to content

Instantly share code, notes, and snippets.

@lunaisnotaboy
Created December 2, 2021 00:56
Show Gist options
  • Save lunaisnotaboy/c0d699d92c83c8af9aa3e9d8ee865398 to your computer and use it in GitHub Desktop.
Save lunaisnotaboy/c0d699d92c83c8af9aa3e9d8ee865398 to your computer and use it in GitHub Desktop.

Revisions

  1. lunaisnotaboy created this gist Dec 2, 2021.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # Shrine `NoMethodError` Issue

    This gist contains all the files relevant to the issue.
    6 changes: 6 additions & 0 deletions image_uploader.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    # frozen_string_literal: true

    class ImageUploader < Shrine
    # There's actually stuff in here in the actual file, but most of it is sensitive.
    # Rest assured, *nothing* in here is causing the problem.
    end
    2 changes: 2 additions & 0 deletions index.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    <!-- Just the image tag -->
    <%= image_tag Topic.find(1).icon_url %>
    16 changes: 16 additions & 0 deletions topic.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # frozen_string_literal: true

    # == Schema Information
    #
    # Table name: topics
    #
    # id :bigint not null, primary key
    # description :text default(""), not null
    # icon_data :text
    # name :string default(""), not null
    # created_at :datetime not null
    # updated_at :datetime not null
    #
    class Topic < ApplicationRecord
    include TopicIconUploader::Attachment(:icon)
    end
    11 changes: 11 additions & 0 deletions topic_icon_uploader.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # frozen_string_literal: true

    class TopicIconUploader < ImageUploader
    # Again, since this code is sensitive, this is as much as I can give you. Apologies.

    plugin :default_url

    Attacher.default_url do |**_options|
    '/images/icons/topic.png'
    end
    end