Add microposts to projects
This commit is contained in:
parent
71a42f109a
commit
5f472c96b8
@ -259,3 +259,4 @@ textarea
|
|||||||
@import profiles
|
@import profiles
|
||||||
@import tokens
|
@import tokens
|
||||||
@import microposts
|
@import microposts
|
||||||
|
@import projects
|
||||||
|
|||||||
10
app/assets/stylesheets/projects.sass
Normal file
10
app/assets/stylesheets/projects.sass
Normal 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
|
||||||
@ -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/
|
|
||||||
@ -1,3 +1,12 @@
|
|||||||
class Project < ActiveRecord::Base
|
class Project < ActiveRecord::Base
|
||||||
belongs_to :user
|
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
|
end
|
||||||
|
|||||||
@ -2,4 +2,4 @@
|
|||||||
- if current_user.following?(@profile)
|
- if current_user.following?(@profile)
|
||||||
= render 'unfollow'
|
= render 'unfollow'
|
||||||
- else
|
- else
|
||||||
= render 'follow'
|
= render 'shared/follow'
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
= @profile.name
|
= @profile.name
|
||||||
- if policy(@profile).edit?
|
- if policy(@profile).edit?
|
||||||
= link_to 'Edit', edit_profile_path(@profile)
|
= 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
|
%p
|
||||||
= @profile.summary
|
= @profile.summary
|
||||||
|
|
||||||
|
|||||||
@ -1,31 +1,22 @@
|
|||||||
%h1 Listing projects
|
.contain
|
||||||
|
%h1 Listing projects
|
||||||
|
|
||||||
-# - if policy(Project).new?
|
-# - if policy(Project).new?
|
||||||
= link_to '+ Add New Project', new_project_path
|
%div{style: "align-self: start;"}
|
||||||
|
= link_to '+ Add New Project', new_project_path
|
||||||
|
|
||||||
%table
|
.projects-index
|
||||||
%thead
|
- @projects.each do |project|
|
||||||
%tr
|
= link_to project, class: "project" do
|
||||||
%th Title
|
%h1= project.title
|
||||||
%th Description
|
%p= project.description
|
||||||
%th Owner
|
-# .social-links
|
||||||
%th
|
- project.social_links.each do |social_link|
|
||||||
%th
|
= social_link.to_icon.html_safe
|
||||||
%th
|
-# %p= project.about
|
||||||
|
-# %span #{project.followers.count} Followers
|
||||||
%tbody
|
-#
|
||||||
- @projects.each do |project|
|
-# %span #{project.microposts.count} Posts
|
||||||
%tr
|
- if policy(project).destroy?
|
||||||
%td= link_to project.title, project
|
= link_to 'Edit', edit_project_path(project)
|
||||||
%td= project.description
|
= link_to 'Delete', project, method: :delete, data: { confirm: 'Are you sure?' }
|
||||||
%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
|
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
- if policy(@project).edit?
|
.contain
|
||||||
= link_to 'Edit', edit_project_path(@project)
|
%h1
|
||||||
|
= @project.title
|
||||||
|
- if policy(@project).edit?
|
||||||
|
= link_to 'Edit', edit_project_path(@project)
|
||||||
|
= render 'shared/follow_form' if current_user.signed_in?
|
||||||
|
|
||||||
%p
|
.description
|
||||||
%b Title:
|
= @project.description
|
||||||
= @project.title
|
|
||||||
%p
|
|
||||||
%b Description:
|
|
||||||
= @project.description
|
|
||||||
%p
|
|
||||||
%b Owner:
|
|
||||||
= @project.user
|
|
||||||
|
|
||||||
|
- if @project.microposts.any?
|
||||||
|
%section.microposts
|
||||||
|
%h3 Posts #{@project.microposts.count}
|
||||||
|
%ol.microposts
|
||||||
|
= render @project.microposts
|
||||||
|
= will_paginate @project.microposts.paginate(page: params[:page])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user