mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-11 09:17:20 -04:00
Adding photos directly to a post
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class Photo < ApplicationRecord
|
||||
include Ownable
|
||||
|
||||
PHOTO_CAPABLE = %w(Garden Planting Harvest Seed).freeze
|
||||
PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post).freeze
|
||||
|
||||
has_many :photographings, foreign_key: :photo_id, dependent: :destroy, inverse_of: :photo
|
||||
has_many :crops, through: :photographings
|
||||
|
||||
@@ -2,6 +2,7 @@ class Post < ApplicationRecord
|
||||
extend FriendlyId
|
||||
include Likeable
|
||||
friendly_id :author_date_subject, use: %i(slugged finders)
|
||||
include PhotoCapable
|
||||
|
||||
#
|
||||
# Relationships
|
||||
@@ -48,6 +49,10 @@ class Post < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def owner_id
|
||||
author_id
|
||||
end
|
||||
|
||||
def to_s
|
||||
subject
|
||||
end
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
%h4 This photo depicts:
|
||||
%p
|
||||
%ul.associations
|
||||
- @photo.posts.each do |post|
|
||||
%li
|
||||
= post_icon
|
||||
= link_to post.subject, post
|
||||
= render "association_delete_button", photo: @photo, type: 'post', thing: post
|
||||
- @photo.plantings.each do |planting|
|
||||
%li
|
||||
= planting_icon
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
= link_to edit_post_path(post), class: 'dropdown-item' do
|
||||
= edit_icon
|
||||
Edit
|
||||
= add_photo_button(post, classes: "dropdown-item")
|
||||
.dropdown-divider
|
||||
- if can? :delete, post
|
||||
= link_to post_path(post), class: 'dropdown-item text-danger', data: { confirm: 'Are you sure?' } do
|
||||
= delete_icon
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
= render 'posts/actions', post: @post
|
||||
.card-body
|
||||
= render 'posts/single', post: @post
|
||||
.index-cards
|
||||
- @post.photos.each do |photo|
|
||||
= render 'photos/thumbnail', photo: photo
|
||||
|
||||
.card-footer
|
||||
= render 'posts/likes', post: @post
|
||||
|
||||
Reference in New Issue
Block a user