-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
197 additions
and
197 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
class CommentsController < ApplicationController | ||
before_filter :authenticate_user! | ||
respond_to :html, :json, :js | ||
|
||
# GET /comments | ||
# GET /comments.json | ||
def index | ||
@comments = Comment.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @comments } | ||
end | ||
end | ||
|
||
# GET /comments/1 | ||
# GET /comments/1.json | ||
def show | ||
@comment = Comment.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @comment } | ||
end | ||
end | ||
|
||
# GET /comments/new | ||
# GET /comments/new.json | ||
def new | ||
@comment = Comment.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @comment } | ||
end | ||
end | ||
|
||
# GET /comments/1/edit | ||
def edit | ||
@comment = Comment.find(params[:id]) | ||
end | ||
|
||
# POST /comments | ||
# POST /comments.json | ||
def create | ||
@comment = current_user.comments.build | ||
@comment.task_id = params[:task_id] | ||
@comment.content = params[:content] | ||
@comment.save | ||
respond_with @comment | ||
end | ||
|
||
# PUT /comments/1 | ||
# PUT /comments/1.json | ||
def update | ||
@comment = Comment.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @comment.update_attributes(params[:comment]) | ||
format.html { redirect_to @comment, notice: 'Comment was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @comment.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /comments/1 | ||
# DELETE /comments/1.json | ||
def destroy | ||
@comment = Comment.find(params[:id]) | ||
@comment.destroy | ||
respond_with @comment | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module CommentsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
= content_tag_for :li, comment, :class => "comment" do | ||
.icon | ||
%a{:href => ""} | ||
= image_tag comment.user.image_url(:thumb), alt: comment.user.name, class: "avatar size128" | ||
%p= nl2br comment.content | ||
- if user_signed_in? && current_user == comment.user | ||
%p= link_to "delete", comment_path(comment), :method => :delete, :remote => true |
8 changes: 4 additions & 4 deletions
8
app/views/activities/_form.html.erb → app/views/comments/_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$('#<%= dom_id(@comment.task) %> textarea').val("") | ||
$('#<%= dom_id(@comment.task) %> .comments ul').prepend("<%= j(render @comment) %>").fadeIn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$('#<%= dom_id(@comment) %>').remove().fadeOut() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing comment</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @comment %> | | ||
<%= link_to 'Back', comments_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<h1>Listing comments</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>User</th> | ||
<th>Content</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @comments.each do |comment| %> | ||
<tr> | ||
<td><%= comment.user_id %></td> | ||
<td><%= comment.content %></td> | ||
<td><%= link_to 'Show', comment %></td> | ||
<td><%= link_to 'Edit', edit_comment_path(comment) %></td> | ||
<td><%= link_to 'Destroy', comment, confirm: 'Are you sure?', method: :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Comment', new_comment_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New comment</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', comments_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>User:</b> | ||
<%= @comment.user_id %> | ||
</p> | ||
|
||
<p> | ||
<b>Content:</b> | ||
<%= @comment.content %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_comment_path(@comment) %> | | ||
<%= link_to 'Back', comments_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...grate/20120519100019_create_activities.rb → db/migrate/20120519100019_create_comments.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.