Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There's still no validation or stylesheets. The various fields in Comment are chosen to include the fields required by the rakismet spam filtering service.
- Loading branch information
Showing
23 changed files
with
195 additions
and
22 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
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 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
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,4 @@ | ||
/* | ||
Place all the styles related to the matching controller here. | ||
They will automatically be included in application.css. | ||
*/ |
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,16 @@ | ||
module RailsBlogEngine | ||
class CommentsController < ApplicationController | ||
before_filter :load_post | ||
|
||
def create | ||
@comment = @post.comments.create(params[:comment]) | ||
redirect_to post_permalink_path(@post) | ||
end | ||
|
||
protected | ||
|
||
def load_post | ||
@post = Post.find(params[:post_id]) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module RailsBlogEngine | ||
module CommentsHelper | ||
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module RailsBlogEngine | ||
class Comment < ActiveRecord::Base | ||
belongs_to :post, :class_name => 'RailsBlogEngine::Post' | ||
|
||
validates :author_byline, :presence => true | ||
validates :body, :presence => true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.rails_blog_engine_comment | ||
%p.byline | ||
Posted | ||
= distance_of_time_in_words_to_now(comment.created_at) | ||
ago by | ||
= comment.author_byline | ||
%div.body~ markdown(comment.body) |
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 @@ | ||
= simple_form_for(comment, :url => post_comments_path(comment.post)) do |f| | ||
= f.input :author_byline | ||
= f.input :author_email | ||
= f.input :author_url | ||
= f.input :body | ||
= f.button :submit, :class => "new_comment btn primary" |
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
21 changes: 21 additions & 0 deletions
21
db/migrate/20111125111958_create_rails_blog_engine_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class CreateRailsBlogEngineComments < ActiveRecord::Migration | ||
def change | ||
create_table :rails_blog_engine_comments do |t| | ||
t.references :post | ||
t.string :author_byline | ||
t.string :author_email | ||
t.string :author_url | ||
t.string :author_ip | ||
t.string :author_user_agent | ||
t.boolean :author_can_post | ||
t.string :referrer | ||
t.string :state | ||
t.text :body | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :rails_blog_engine_comments, :post_id | ||
add_index :rails_blog_engine_comments, :author_email | ||
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
22 changes: 22 additions & 0 deletions
22
spec/controllers/rails_blog_engine/comments_controller_spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'spec_helper' | ||
|
||
# This spec was generated by rspec-rails when you ran the scaffold generator. | ||
# It demonstrates how one might use RSpec to specify the controller code that | ||
# was generated by Rails when you ran the scaffold generator. | ||
# | ||
# It assumes that the implementation code is generated by the rails scaffold | ||
# generator. If you are using any extension libraries to generate different | ||
# controller code, this generated spec may or may not pass. | ||
# | ||
# It only uses APIs available in rails and/or rspec-rails. There are a number | ||
# of tools you can use to make these specs even more expressive, but we're | ||
# sticking to rails and rspec-rails APIs to keep things simple and stable. | ||
# | ||
# Compared to earlier versions of this generator, there is very limited use of | ||
# stubs and message expectations in this spec. Stubs are only used when there | ||
# is no simpler way to get a handle on the object needed for the example. | ||
# Message expectations are only used when there is no simpler way to specify | ||
# that an instance is receiving a specific message. | ||
|
||
describe RailsBlogEngine::CommentsController do | ||
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,14 @@ | ||
require 'spec_helper' | ||
|
||
# Specs in this file have access to a helper object that includes | ||
# the CommentsHelper. For example: | ||
# | ||
# describe CommentsHelper do | ||
# describe "string concat" do | ||
# it "concats two strings with spaces" do | ||
# helper.concat_strings("this","that").should == "this that" | ||
# end | ||
# end | ||
# end | ||
describe RailsBlogEngine::CommentsHelper do | ||
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsBlogEngine::Comment do | ||
it { should belong_to(:post) } | ||
|
||
it { should_not allow_value('').for(:author_byline) } | ||
it { should_not allow_value('').for(:body) } | ||
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