0

I want to be able to add an attachment icon to actiontext bubbles that have an attachment.

- if m.body <has_file_attached?>
  %div{class: 'far fa-paperclip'

Kind of thing...

Even better if its also something i could use in an query like:

Message.where(<body has attachment>)

I suppose I could do something like

Message.where('body LIKE ?', "%<figure%")

But thats pretty sloppy.

Ideas?

bryanfeller
  • 336
  • 4
  • 8

1 Answers1

0

so for the first thing

- unless m.body.embeds.empty?
  %div{class: 'far fa-paperclip'}

Although I couldn't find a clean way to do a query. Would still be nice to see any ideas on that.

I stacked queries for now to get the job done:

- messages.each do |m|
  - unless m.body.embeds.empty?
    <doing things>

Which is horribly inefficient. I will probably rock some includes, maybe even do a select to trim down the load time, but really there must be a better way.

bryanfeller
  • 336
  • 4
  • 8