Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added ability to comment on games
- Loading branch information
stevetuckner@stewdle.com
committed
Sep 19, 2011
1 parent
ae2d008
commit 8503f90
Showing
18 changed files
with
158 additions
and
11 deletions.
There are no files selected for viewing
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,17 @@ | ||
class CommentsController < ApplicationController | ||
actions :create, :update | ||
belongs_to :game | ||
|
||
def create | ||
@comment = Comment.new(params[:comment]) | ||
@comment.user = current_user | ||
@comment.game = Game.find(params[:game_id]) | ||
puts "********** = #{request.host}" | ||
puts "********** = #{request.port}" | ||
puts "********** = #{request.protocol}" | ||
UserMailer.comment_email(@comment, @comment.game.players_and_commenters - [@comment.user], request).deliver | ||
create! do |format| | ||
format.html {redirect_to game_path(@comment.game)} | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class UserMailer < ActionMailer::Base | ||
helper :application | ||
|
||
def comment_email(comment, to, request) | ||
@request = request | ||
@comment = comment | ||
mail( :from => "no-reply@chess-talk.com", | ||
:to => to.map{|user| user.email}, | ||
:subject => "#{comment.user.name} has commented on the game #{comment.game.description}") | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class Comment < ActiveRecord::Base | ||
belongs_to :user | ||
belongs_to :game | ||
|
||
default_scope :order => "id desc" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= f.input :move, :as => :hidden | ||
= f.input :text, :size => 5 | ||
= f.submit "Add Comment" |
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,3 @@ | ||
= semantic_form_for [game, comment] do |f| | ||
= f.inputs do | ||
= render :partial => "comments/form", :locals => {:f => f} |
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,12 @@ | ||
.comment | ||
.medsmall-title Name | ||
.medsmall-value= comment.user.name | ||
/.medsmall-title When | ||
/.medsmall-value= comment.datetime | ||
- if comment.move | ||
.medsmall-title Move | ||
.medsmall-value= comment.move | ||
.medsmall-title Comment | ||
.medsmall-value= comment.text | ||
.clear | ||
|
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,11 @@ | ||
%div{:style => "background-color: #FF0000; color: white;padding:20px;"} | ||
%div{:style => "background-color: #DD0000;"} | ||
%h1 | ||
%img{:src => image_url("logo-small.png", @request)} | ||
Chess-Talk Comment | ||
%div{:style => "background-color: #770000; padding:5px; border-radius:3px;"} | ||
%p | ||
= link_to @comment.user.name, user_url(@comment.user), :style => "color: white; link-decoration: none; font-weight: bold;" | ||
has commented on the game | ||
= link_to @comment.game.description, game_url(@comment.game), :style => "color: white; link-decoration: none; font-weight: bold;" | ||
%p= @comment.text |
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 @@ | ||
Chess-Talk comment: | ||
|
||
<%= @comment.user.name %> has commented on the game <%= @comment.game.description %> | ||
<%= @comment.text %> |
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 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