Skip to content

Last completed in class #39

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
10 changes: 5 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ class ApplicationController < ActionController::Base
# Make sure you run `rails sample_data`
# Delete this code when the issue is resolved.

# helper_method :current_user
helper_method :current_user

# def current_user
# @alice ||= User.find_by! username: "alice"
# end
def current_user
@alice ||= User.find_by! username: "alice"
end

# skip_forgery_protection
skip_forgery_protection

# End hacks.
##############################################################################
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ def create
if @comment.save
format.html { redirect_back fallback_location: root_path, notice: "Comment was successfully created." }
format.json { render :show, status: :created, location: @comment }
format.js
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @comment.errors, status: :unprocessable_entity }

end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<li class="list-group-item">
<%= form_with(model: comment) do |form| %>
<li id="photo_<%= @comment.photo.id %>new_comment_form" class="list-group-item">
<%= form_with(model: comment, local:false) do |form| %>
<% if comment.errors.any? %>
<div id="error_explanation">
<ul class="list-unstyled">
Expand Down
1 change: 1 addition & 0 deletions app/views/comments/create.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$("#photo_<%= @comment.photo.id %>new_comment_form").slideUp();
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "vanilla-rails",
"private": true,
"dependencies": {
"@rails/webpacker": "5.4.3",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12"
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "5.2.1",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3"
"webpack-dev-server": "^3.11.2"
}
}
15 changes: 0 additions & 15 deletions package.json.old

This file was deleted.

Loading