Add microposts to projects

This commit is contained in:
Jesse C. Fisher 2023-11-21 11:57:29 +00:00 committed by TheNeedful-DO
parent 768f89eecf
commit 3368617fb3
8 changed files with 56 additions and 45 deletions

View File

@ -259,3 +259,4 @@ textarea
@import profiles
@import tokens
@import microposts
@import projects

View File

@ -0,0 +1,10 @@
.projects-index
.project
text-align: center
&:hover h1
text-shadow: 0px 0px 9px #e1b027
h1
text-shadow: -1px 1px #e1b027, 1px -1px #00ddff
transition: .15s text-shadow
p
margin-top: 0

View File

@ -1,3 +0,0 @@
// Place all the styles related to the Projects controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/

View File

@ -1,3 +1,12 @@
class Project < ActiveRecord::Base
belongs_to :user
has_many :microposts, as: :micropostable
has_many :passive_relationships, class_name: "Relationship",
foreign_key: "followed_id",
dependent: :destroy
has_many :followers, through: :passive_relationships, source: :follower
def display_name
title
end
end

View File

@ -2,4 +2,4 @@
- if current_user.following?(@profile)
= render 'unfollow'
- else
= render 'follow'
= render 'shared/follow'

View File

@ -3,7 +3,7 @@
= @profile.name
- if policy(@profile).edit?
= link_to 'Edit', edit_profile_path(@profile)
= render 'follow_form' if current_user.signed_in?
= render 'shared/follow_form' if current_user.signed_in?
%p
= @profile.summary

View File

@ -1,31 +1,22 @@
%h1 Listing projects
.contain
%h1 Listing projects
-# - if policy(Project).new?
= link_to '+ Add New Project', new_project_path
-# - if policy(Project).new?
%div{style: "align-self: start;"}
= link_to '+ Add New Project', new_project_path
%table
%thead
%tr
%th Title
%th Description
%th Owner
%th
%th
%th
%tbody
- @projects.each do |project|
%tr
%td= link_to project.title, project
%td= project.description
%td= project.user
-# %td= link_to 'Show', project
%td
- if policy(project).edit?
%td= link_to 'Edit', edit_project_path(project)
- else
%td
- if policy(project).destroy?
%td= link_to 'Destroy', project, method: :delete, data: { confirm: 'Are you sure?' }
- else
%td
.projects-index
- @projects.each do |project|
= link_to project, class: "project" do
%h1= project.title
%p= project.description
-# .social-links
- project.social_links.each do |social_link|
= social_link.to_icon.html_safe
-# %p= project.about
-# %span #{project.followers.count} Followers
-# &nbsp;&nbsp;
-# %span #{project.microposts.count} Posts
- if policy(project).destroy?
= link_to 'Edit', edit_project_path(project)
= link_to 'Delete', project, method: :delete, data: { confirm: 'Are you sure?' }

View File

@ -1,13 +1,16 @@
- if policy(@project).edit?
= link_to 'Edit', edit_project_path(@project)
.contain
%h1
= @project.title
- if policy(@project).edit?
= link_to 'Edit', edit_project_path(@project)
= render 'shared/follow_form' if current_user.signed_in?
%p
%b Title:
= @project.title
%p
%b Description:
= @project.description
%p
%b Owner:
= @project.user
.description
= @project.description
- if @project.microposts.any?
%section.microposts
%h3 Posts #{@project.microposts.count}
%ol.microposts
= render @project.microposts
= will_paginate @project.microposts.paginate(page: params[:page])