Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ end
gem "starter_generators", :git => "https://github.com/raghubetina/starter_generators"
gem 'devise'
gem 'font-awesome-sass', '~> 4.7.0'


gem 'carrierwave'
63 changes: 38 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GIT

GIT
remote: git://github.com/firstdraft/grade_runner.git
revision: 1e212e50b3fd46ff5b22783d19e0e1aac7928915
revision: b3664d1fe94177cd5c2943b9b3b08e4c81343e71
specs:
grade_runner (0.0.1)

Expand Down Expand Up @@ -74,30 +74,35 @@ GEM
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 13.0)
arel (7.1.4)
autoprefixer-rails (7.1.2.3)
autoprefixer-rails (7.1.2.6)
execjs
awesome_print (1.8.0)
bcrypt (3.1.11)
better_errors (2.1.1)
better_errors (2.3.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
erubi (>= 1.0.0)
rack (>= 0.9.0)
bindex (0.5.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap (4.0.0.alpha6)
bootstrap (4.0.0.beta)
autoprefixer-rails (>= 6.0.3)
popper_js (~> 1.11.1)
sass (>= 3.4.19)
builder (3.2.3)
byebug (9.0.6)
callsite (0.0.11)
capybara (2.14.0)
capybara (2.15.1)
addressable
mime-types (>= 1.16)
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
carrierwave (1.1.0)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
coderay (1.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
Expand All @@ -122,6 +127,7 @@ GEM
dotenv-rails (2.2.1)
dotenv (= 2.2.1)
railties (>= 3.2, < 5.2)
erubi (1.6.1)
erubis (2.7.0)
execjs (2.7.0)
factory_girl (4.8.0)
Expand All @@ -136,10 +142,10 @@ GEM
sass (>= 3.2)
globalid (0.4.0)
activesupport (>= 4.2.0)
hashdiff (0.3.4)
i18n (0.8.1)
jbuilder (2.6.4)
activesupport (>= 3.0.0)
hashdiff (0.3.5)
i18n (0.8.6)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
Expand All @@ -155,7 +161,7 @@ GEM
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.5)
mail (2.6.6)
mime-types (>= 1.16, < 4)
meta_request (0.4.3)
callsite (~> 0.0, >= 0.0.11)
Expand All @@ -165,18 +171,20 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.2)
mini_mime (0.1.4)
mini_portile2 (2.2.0)
minitest (5.10.3)
multi_json (1.12.1)
nio4r (2.0.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
octicons (3.0.1)
nio4r (2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
octicons (4.0.2)
nokogiri (>= 1.6.3.1)
octicons_helper (3.0.1)
octicons (~> 3.0)
octicons_helper (4.0.1)
octicons (~> 4.0)
rails
orm_adapter (0.5.0)
popper_js (1.11.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand Down Expand Up @@ -228,7 +236,7 @@ GEM
rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-rails (3.6.0)
rspec-rails (3.6.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
Expand All @@ -238,7 +246,11 @@ GEM
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
safe_yaml (1.0.4)
sass (3.4.23)
sass (3.5.1)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
Expand All @@ -261,7 +273,7 @@ GEM
rails (>= 3.1)
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
tilt (2.0.8)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
Expand All @@ -285,7 +297,7 @@ GEM
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
xpath (2.0.0)
xpath (2.1.0)
nokogiri (~> 1.3)

PLATFORMS
Expand All @@ -298,6 +310,7 @@ DEPENDENCIES
binding_of_caller
byebug
capybara
carrierwave
coffee-rails (~> 4.1.0)
database_cleaner
devise
Expand Down Expand Up @@ -327,4 +340,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
1.15.2
1.15.3
12 changes: 12 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

before_action :authenticate_user!

before_action :configure_permitted_parameters, if: :devise_controller?

protected

def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, :keys => [:username])

devise_parameter_sanitizer.permit(:account_update, :keys => [])
end
end
69 changes: 69 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
class CommentsController < ApplicationController
def index
@comments = Comment.all

render("comments/index.html.erb")
end

def show
@comment = Comment.find(params[:id])

render("comments/show.html.erb")
end

def new
@comment = Comment.new

render("comments/new.html.erb")
end

def create
@comment = Comment.new

@comment.photo_id = params[:photo_id]
@comment.body = params[:body]
@comment.user_id = params[:user_id]

save_status = @comment.save

if save_status == true
redirect_to("/comments/#{@comment.id}", :notice => "Comment created successfully.")
else
render("comments/new.html.erb")
end
end

def edit
@comment = Comment.find(params[:id])

render("comments/edit.html.erb")
end

def update
@comment = Comment.find(params[:id])

@comment.photo_id = params[:photo_id]
@comment.body = params[:body]
@comment.user_id = params[:user_id]

save_status = @comment.save

if save_status == true
redirect_to("/comments/#{@comment.id}", :notice => "Comment updated successfully.")
else
render("comments/edit.html.erb")
end
end

def destroy
@comment = Comment.find(params[:id])

@comment.destroy

if URI(request.referer).path == "/comments/#{@comment.id}"
redirect_to("/", :notice => "Comment deleted.")
else
redirect_to(:back, :notice => "Comment deleted.")
end
end
end
67 changes: 67 additions & 0 deletions app/controllers/likes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
class LikesController < ApplicationController
def index
@likes = Like.all

render("likes/index.html.erb")
end

def show
@like = Like.find(params[:id])

render("likes/show.html.erb")
end

def new
@like = Like.new

render("likes/new.html.erb")
end

def create
@like = Like.new

@like.user_id = params[:user_id]
@like.photo_id = params[:photo_id]

save_status = @like.save

if save_status == true
redirect_to("/likes/#{@like.id}", :notice => "Like created successfully.")
else
render("likes/new.html.erb")
end
end

def edit
@like = Like.find(params[:id])

render("likes/edit.html.erb")
end

def update
@like = Like.find(params[:id])

@like.user_id = params[:user_id]
@like.photo_id = params[:photo_id]

save_status = @like.save

if save_status == true
redirect_to("/likes/#{@like.id}", :notice => "Like updated successfully.")
else
render("likes/edit.html.erb")
end
end

def destroy
@like = Like.find(params[:id])

@like.destroy

if URI(request.referer).path == "/likes/#{@like.id}"
redirect_to("/", :notice => "Like deleted.")
else
redirect_to(:back, :notice => "Like deleted.")
end
end
end
Loading