Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
blog_comments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mis-21-2018-intersession
rails
blog_comments
Commits
c20af6ef
Commit
c20af6ef
authored
Jul 11, 2018
by
John Noel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished setup of models
parent
5268e222
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
59 additions
and
0 deletions
+59
-0
comments.coffee
app/assets/javascripts/comments.coffee
+3
-0
comments.scss
app/assets/stylesheets/comments.scss
+3
-0
comments_controller.rb
app/controllers/comments_controller.rb
+4
-0
comments_helper.rb
app/helpers/comments_helper.rb
+2
-0
comment.rb
app/models/comment.rb
+4
-0
post.rb
app/models/post.rb
+1
-0
user.rb
app/models/user.rb
+1
-0
new.html.erb
app/views/comments/new.html.erb
+2
-0
routes.rb
config/routes.rb
+1
-0
20180711135455_create_comments.rb
db/migrate/20180711135455_create_comments.rb
+11
-0
comments_controller_test.rb
test/controllers/comments_controller_test.rb
+9
-0
comments.yml
test/fixtures/comments.yml
+11
-0
comment_test.rb
test/models/comment_test.rb
+7
-0
No files found.
app/assets/javascripts/comments.coffee
0 → 100644
View file @
c20af6ef
# 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/
app/assets/stylesheets/comments.scss
0 → 100644
View file @
c20af6ef
// 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/
app/controllers/comments_controller.rb
0 → 100644
View file @
c20af6ef
class
CommentsController
<
ApplicationController
def
new
end
end
app/helpers/comments_helper.rb
0 → 100644
View file @
c20af6ef
module
CommentsHelper
end
app/models/comment.rb
0 → 100644
View file @
c20af6ef
class
Comment
<
ApplicationRecord
belongs_to
:user
belongs_to
:post
end
\ No newline at end of file
app/models/post.rb
View file @
c20af6ef
class
Post
<
ApplicationRecord
class
Post
<
ApplicationRecord
belongs_to
:user
belongs_to
:user
has_many
:comments
end
end
\ No newline at end of file
app/models/user.rb
View file @
c20af6ef
...
@@ -4,6 +4,7 @@ class User < ApplicationRecord
...
@@ -4,6 +4,7 @@ class User < ApplicationRecord
devise
:database_authenticatable
,
:registerable
,
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_many
:posts
has_many
:posts
has_many
:comments
def
to_s
def
to_s
if
first_name
&&
last_name
if
first_name
&&
last_name
...
...
app/views/comments/new.html.erb
0 → 100644
View file @
c20af6ef
<h1>
Comments#new
</h1>
<p>
Find me in app/views/comments/new.html.erb
</p>
config/routes.rb
View file @
c20af6ef
Rails
.
application
.
routes
.
draw
do
Rails
.
application
.
routes
.
draw
do
get
'comments/new'
devise_for
:users
devise_for
:users
devise_scope
:user
do
devise_scope
:user
do
authenticated
:user
do
authenticated
:user
do
...
...
db/migrate/20180711135455_create_comments.rb
0 → 100644
View file @
c20af6ef
class
CreateComments
<
ActiveRecord
::
Migration
[
5.2
]
def
change
create_table
:comments
do
|
t
|
t
.
text
:comment
t
.
references
:user
,
foreign_key:
true
t
.
references
:post
,
foreign_key:
true
t
.
timestamps
end
end
end
test/controllers/comments_controller_test.rb
0 → 100644
View file @
c20af6ef
require
'test_helper'
class
CommentsControllerTest
<
ActionDispatch
::
IntegrationTest
test
"should get new"
do
get
comments_new_url
assert_response
:success
end
end
test/fixtures/comments.yml
0 → 100644
View file @
c20af6ef
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one
:
comment
:
MyText
user
:
one
post
:
one
two
:
comment
:
MyText
user
:
two
post
:
two
test/models/comment_test.rb
0 → 100644
View file @
c20af6ef
require
'test_helper'
class
CommentTest
<
ActiveSupport
::
TestCase
# test "the truth" do
# assert true
# end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment