Skip to content

Commit

Permalink
Merge pull request #160 from EleoXDA/3lbay
Browse files Browse the repository at this point in the history
fix event photo in Heroku
  • Loading branch information
Nirajan Wagle authored Sep 15, 2022
2 parents ee5433c + aceeaee commit e379350
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 8 additions & 8 deletions app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require "open-uri"

class Event < ApplicationRecord
after_create :set_default_event_avatar
# after_create :set_default_event_avatar
has_one_attached :photo

def set_default_event_avatar
return if photo.attached?
# def set_default_event_avatar
# return if photo.attached?

path = "https://res.cloudinary.com/dp6zhyocx/image/upload/v1662046666/pqwya0pvqts4ubv0eqi6.jpg"
file = URI.open(path)
photo.attach(io: file, filename: "userphoto.png", content_type: "image/png")
save
end
# path = "https://res.cloudinary.com/dp6zhyocx/image/upload/v1662046666/pqwya0pvqts4ubv0eqi6.jpg"
# file = URI.open(path)
# photo.attach(io: file, filename: "userphoto.png", content_type: "image/png")
# save
# end
end
3 changes: 1 addition & 2 deletions app/views/events/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<% if @event.photo.attached? %>
<%= cl_image_tag @event.photo.key, class: "event-image" %>
<% else %>
<img src="<%= @event.image %>", class="event-image" >
<%#= image_tag @event.image, class: "event-image" %>
<%= image_tag "userphoto_square.jpg", class: "event-image" %>
<% end %>
</div>
<%= link_to "Tickets", "#",class: "event-button" %> <br><br>
Expand Down

0 comments on commit e379350

Please sign in to comment.