Paperclip: integration with mailboxer gem
Two solutions:
use the built-in attachment made with carrierwave (source)
monkey patch the
Message
model:
Message.class_eval do
#your paperclip code goes here
end
And don't forget migrations! Adding belongs to relationship to Ruby Gem Mailboxer
Although rewriting a custom Conversation system will be the best long-term solution providing the customization requirement (Like linking with other models for instance), to save some time at the moment I have implement the link with a ConversationLink
Model. I hope it would be useful for anyone in the future who are at my position.
Model: conversation_link.rb
class ConversationLink < ActiveRecord::Base
belongs_to :conversation
belongs_to :linkingObject, polymorphic: true
end
then in each models I target to link with the conversation
, I just add: has_many :conversation_link, as: :linkingObject
This will only allow you to get the related conversation from the linking object, but the coding for reverse linking can be done via functions defined in a Module.This is not a perfect solution, but at least I do not need to monkey patch the gem...
Create link_to for downloading a File from Paperclip gem?
Suppose your model is Boxholder
If you have @boxholder instance variable in your controller like:
@boxholder = Boxholder.find(params[:id])
Then the following line could be your solution: <%= link_to @boxholder.box_file_name,@boxholder.box.url %>
Bundler loaded gem order
I had to add a Railtie to make this work. Paperclip was loading before my gem but wasn't include until much later...
Why is my app trying to load bourbon?
Bourbon is a dependency in Administrate. Looks like there is a recent, open issue around this: https://github.com/thoughtbot/administrate/pull/673.
Related Topics
How to Remove Ruby on Rails 4 Beta
Giving an Example of a Cycle in a Directed Graph
Operator Precedence of Unary Operators
Rails Has_Many Through Form with Additional Attributes
Stripping Commas from Integers or Decimals in Rails
Completely Random Identifier of a Given Length
Sorting a Hash in Ruby Based on Value and Then Key
How to Render Blob Images in a Prawn Document
How to Calculate a String's Width in Ruby
Do Ruby Objects Have a Size Limit
Include Module in All Minitest Tests Like in Rspec
Proper Usage of Ruby Statement Modifiers
Facebook Redirect Url in Ruby on Rails Open Ssl Error
Why Does Ruby Parallel Assignment with Array of Strings Returns String