-
Notifications
You must be signed in to change notification settings - Fork 0
Integration #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Integration #1
Changes from all commits
cb479ec
89a0d9d
6995e99
de96dbb
a5fbabb
8d81025
6ca1725
86269ca
7b49308
8184234
08b15cc
63a82bc
6eb0da9
a7f7bc9
9e21189
2e627ae
49c591b
7e93059
eeaaf37
226401c
4580006
fd51ac2
84a0430
49a7f5a
8f08b31
8d623ee
01efa87
8bb1bb1
60e2adc
76083ba
3b4f610
fa39548
306fe4c
4da1076
186f827
9546afc
5715260
632ac8d
9fc29d8
abd7d87
ef54842
e6926a6
4f03df1
38a4cfb
8d89f00
2e45b85
6c063db
cc7cc2b
a6ef349
6096642
67a7074
5d2f918
30cab77
46fb16a
fe04a77
195727d
eadae0e
e830f12
6174a5f
c05082a
aefb538
fbd299d
6b956ba
457ffe5
9f4ad16
6f68c92
ff50791
c99be8e
4b9d4eb
ceb1a89
f590f3b
f492423
39cd958
657b744
4cbbc67
5e140d7
d2e5eb2
35abc36
390e49b
66f15b7
8dd1bd6
a09af43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,7 @@ | |
| /log/* | ||
| !/log/.keep | ||
| /tmp | ||
| models_setup.txt | ||
| models_setup.txt~ | ||
| public/img/ | ||
| .byebug_history | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --color | ||
| --require spec_helper |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| body { padding-top: 70px; } | ||
|
|
||
| @import "bootstrap-sprockets"; | ||
| @import "bootstrap" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the comments controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.com/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the favourites controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.com/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the home controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.com/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the posts controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.com/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the sessions controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.com/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the users controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.com/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| class CommentsController < ApplicationController | ||
|
|
||
| before_action :authenticate_user! | ||
| before_action(:find_comment, {only: [:show, :edit, :update, :destroy]}) | ||
| before_action :authorize_comment, only: [:edit, :update, :destroy] | ||
|
|
||
|
|
||
| def index | ||
| @comments = Comment.all | ||
| end | ||
|
|
||
| def new | ||
| @comment = Comment.new | ||
| end | ||
|
|
||
| def create | ||
| @post = Post.find params[:post_id] | ||
| @comment = Comment.new(comment_params) | ||
| @comment.post = @post | ||
| @comment.user = current_user | ||
| respond_to do |format| | ||
| if @comment.save | ||
| flash[:notice] = "Comment Created" | ||
| format.html { redirect_to post_path(@post) } | ||
| format.js { render :reload } | ||
| else | ||
| flash[:alert] = "Error! Comment not created" | ||
| format.html { render "/posts/show" } | ||
| format.js { render :reload } | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def edit | ||
| end | ||
|
|
||
| # def update | ||
| # if @comment.update comment_params | ||
| # redirect_to comment_path(@comment), notice: "Comment updated!" | ||
| # else | ||
| # render :edit | ||
| # end | ||
| # end | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happened to the commented out update action? |
||
| def show | ||
| end | ||
|
|
||
| def destroy | ||
| @post = Post.find params[:post_id] | ||
| @comment.destroy | ||
| redirect_to post_path(@post), notice: "Your comment was deleted." | ||
| end | ||
|
|
||
|
|
||
| private | ||
|
|
||
| def find_comment | ||
| @comment = Comment.find params[:id] | ||
| end | ||
|
|
||
| def authorize_comment | ||
| flash[:alert] = "You do not have permission to manage this comment" | ||
| redirect_to root_path unless can? :manage, @comment | ||
| end | ||
|
|
||
| def comment_params | ||
| params.require(:comment).permit(:body) | ||
| end | ||
|
|
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| class FavouritesController < ApplicationController | ||
| before_action :authenticate_user! | ||
| before_action :find_post, only: [:create, :destroy] | ||
|
|
||
| def create | ||
| favourite = Favourite.new | ||
| favourite.post = @post | ||
| favourite.user = current_user | ||
| respond_to do |format| | ||
| if favourite.save | ||
| format.html { redirect_to post_path(@post), notice: "Thanks for favouriting!" } | ||
| format.js { render :modify_favourite } | ||
| else | ||
| format.html { redirect_to post_path(@post), alert: "Can't favourite! Have you already favourited?" } | ||
| format.js { render :modify_favourite } | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| favourite = current_user.favourites.find params[:id] | ||
| favourite.destroy | ||
| respond_to do |format| | ||
| format.html { redirect_to post_path(@post), notice: "Favourite removed!" } | ||
| format.js { render :modify_favourite } | ||
| end | ||
| end | ||
|
|
||
| def index | ||
| @favourites = current_user.favourites.all | ||
| end | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a user do not have any favourite post, it will throw an exception. Please refer my notes on favourites/index.html.erb |
||
|
|
||
| private | ||
|
|
||
| def find_post | ||
| @post ||= Post.find params[:post_id] | ||
| end | ||
|
|
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Home and static pages go in HomeController | ||
| class HomeController < ApplicationController | ||
| def home | ||
|
|
||
| end | ||
|
|
||
| def about | ||
|
|
||
| end | ||
|
|
||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just write
before_action :find_comment, only: [:show, :edit, :update, :destroy]
to make them consistent.