Skip to content
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

Bijo case comment #43

Open
wants to merge 6 commits into
base: master
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
3 changes: 3 additions & 0 deletions Project/app/assets/javascripts/b_log_comment.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions Project/app/assets/javascripts/comment.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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/
3 changes: 3 additions & 0 deletions Project/app/assets/stylesheets/b_log_comment.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the BLogComment controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions Project/app/assets/stylesheets/comment.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the comment controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
2 changes: 2 additions & 0 deletions Project/app/controllers/b_log_comment_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class BLogCommentController < ApplicationController
end
15 changes: 15 additions & 0 deletions Project/app/controllers/blogs_comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This controller is to generate comments
#Author Bergitte
class BlogsCommentsController < ApplicationController
def create
@blog = Blog.find(params[:blog_id])
@blogComment = @blog.BlogComments.create(blogComment_params)
redirect_to blog_path(@blog)
end

private
def comment_params
params.require(:blogComment).permit(:commenter, :body)
end

end
2 changes: 2 additions & 0 deletions Project/app/controllers/comment_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class CommentController < ApplicationController
end
2 changes: 2 additions & 0 deletions Project/app/helpers/b_log_comment_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module BLogCommentHelper
end
2 changes: 2 additions & 0 deletions Project/app/helpers/blogComments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module BlogCommentsHelper
end
2 changes: 2 additions & 0 deletions Project/app/helpers/comment_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CommentHelper
end
1 change: 1 addition & 0 deletions Project/app/models/blog.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Blog < ActiveRecord::Base
has_many :blog_comments
end
3 changes: 3 additions & 0 deletions Project/app/models/blog_comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class BlogComment < ActiveRecord::Base
belongs_to :blog
end
33 changes: 30 additions & 3 deletions Project/app/views/blogs/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!--<p id="notice"><%= notice %></p>-->

# This view is to show the comments on case study
# Author Bergitte
<p>
<strong>Title:</strong>
<%= @blog.title %>
Expand All @@ -10,5 +11,31 @@
<%= @blog.content %>
</p>


<%= link_to 'Back', blogs_path %>
<h2>Comments</h2>
<% @blog.blogs_Comments.each do |blog_Comment| %>
<p>
<strong>Commenter:</strong>
<%= blogs_comments.commenter %>
</p>

<p>
<strong>Blogcomment:</strong>
<%= blogs_comments.body %>
</p>
<% end %>

<h2>Add a comment:</h2>
<%= form_for([@blog, @blog.blogs_comments.build]) do |f| %>
<p>
<%= f.label :user_id %><br>
<%= f.text_field :user_id %>
</p>
<p>
<%= f.label :body %><br>
<%= f.text_area :body %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
<%= link_to 'Back', blogs_path %>
21 changes: 5 additions & 16 deletions Project/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
Rails.application.routes.draw do
resources :blogs

resources :consultancies

devise_for :views
devise_for :users
resources :events
resources :pitches do
member do
get 'evaluateIdeaConsultant'
get 'submitTheForm'
end
end


resources :pitches do
resources :comments
resources :blogs do
resources :blogComments
end


resources :consultancies
get 'pages/home'
get 'users/show'
get 'events/userview'
Expand All @@ -27,9 +19,6 @@
get 'pages/signup'
get 'pages/login'
root 'pages#home'
get 'approve' => 'consultancies#approve'
post 'approve' => 'consultancies#approve'
match 'users/:id/approve'=> 'users#approve_user', :via => [:get], as: 'approve_user'


# The priority is based upon order of creation: first created -> highest priority.
Expand Down
11 changes: 11 additions & 0 deletions Project/db/migrate/20150429133753_create_blog_comments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateBlogComments < ActiveRecord::Migration
def change
create_table :blog_comments do |t|
t.integer :blog_id
t.integer :user_id
t.text :body

t.timestamps null: false
end
end
end
10 changes: 9 additions & 1 deletion Project/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150423171740) do
ActiveRecord::Schema.define(version: 20150429133753) do

create_table "blog_comments", force: :cascade do |t|
t.integer "blog_id"
t.integer "user_id"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "blogs", force: :cascade do |t|
t.string "title"
Expand Down
2 changes: 1 addition & 1 deletion Project/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
user.save!



admin_user1 = User.new( :email => '[email protected]', :password => '12345678')
admin_user1.admin = true
admin_user1.approved = true
Expand All @@ -29,3 +28,4 @@
ideator_user1.is_Ideator = true
ideator_user1.approved = true
ideator_user1.save!

2 changes: 1 addition & 1 deletion Project/i2b
Submodule i2b updated from 279b9a to b2afbf
7 changes: 7 additions & 0 deletions Project/test/controllers/b_log_comment_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class BLogCommentControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
2 changes: 2 additions & 0 deletions Project/test/controllers/blogComments_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

In progess
7 changes: 7 additions & 0 deletions Project/test/controllers/comment_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class CommentControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
11 changes: 11 additions & 0 deletions Project/test/fixtures/blog_comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
blog_id: 1
user_id: 1
body: MyText

two:
blog_id: 1
user_id: 1
body: MyText
7 changes: 7 additions & 0 deletions Project/test/models/blog_comment_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class BlogCommentTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end