diff --git a/Project/app/assets/javascripts/b_log_comment.coffee b/Project/app/assets/javascripts/b_log_comment.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/Project/app/assets/javascripts/b_log_comment.coffee @@ -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/ diff --git a/Project/app/assets/javascripts/comment.coffee b/Project/app/assets/javascripts/comment.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/Project/app/assets/javascripts/comment.coffee @@ -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/ diff --git a/Project/app/assets/stylesheets/b_log_comment.scss b/Project/app/assets/stylesheets/b_log_comment.scss new file mode 100644 index 0000000..595c09f --- /dev/null +++ b/Project/app/assets/stylesheets/b_log_comment.scss @@ -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/ diff --git a/Project/app/assets/stylesheets/comment.scss b/Project/app/assets/stylesheets/comment.scss new file mode 100644 index 0000000..62da4c8 --- /dev/null +++ b/Project/app/assets/stylesheets/comment.scss @@ -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/ diff --git a/Project/app/controllers/b_log_comment_controller.rb b/Project/app/controllers/b_log_comment_controller.rb new file mode 100644 index 0000000..0f9ad91 --- /dev/null +++ b/Project/app/controllers/b_log_comment_controller.rb @@ -0,0 +1,2 @@ +class BLogCommentController < ApplicationController +end diff --git a/Project/app/controllers/blogs_comments_controller.rb b/Project/app/controllers/blogs_comments_controller.rb new file mode 100644 index 0000000..24321ad --- /dev/null +++ b/Project/app/controllers/blogs_comments_controller.rb @@ -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 diff --git a/Project/app/controllers/comment_controller.rb b/Project/app/controllers/comment_controller.rb new file mode 100644 index 0000000..1599b9b --- /dev/null +++ b/Project/app/controllers/comment_controller.rb @@ -0,0 +1,2 @@ +class CommentController < ApplicationController +end diff --git a/Project/app/helpers/b_log_comment_helper.rb b/Project/app/helpers/b_log_comment_helper.rb new file mode 100644 index 0000000..7d6cb37 --- /dev/null +++ b/Project/app/helpers/b_log_comment_helper.rb @@ -0,0 +1,2 @@ +module BLogCommentHelper +end diff --git a/Project/app/helpers/blogComments_helper.rb b/Project/app/helpers/blogComments_helper.rb new file mode 100644 index 0000000..85a80c7 --- /dev/null +++ b/Project/app/helpers/blogComments_helper.rb @@ -0,0 +1,2 @@ +module BlogCommentsHelper +end \ No newline at end of file diff --git a/Project/app/helpers/comment_helper.rb b/Project/app/helpers/comment_helper.rb new file mode 100644 index 0000000..2466d7e --- /dev/null +++ b/Project/app/helpers/comment_helper.rb @@ -0,0 +1,2 @@ +module CommentHelper +end diff --git a/Project/app/models/blog.rb b/Project/app/models/blog.rb index 0ad9473..d1171bd 100644 --- a/Project/app/models/blog.rb +++ b/Project/app/models/blog.rb @@ -1,2 +1,3 @@ class Blog < ActiveRecord::Base + has_many :blog_comments end diff --git a/Project/app/models/blog_comment.rb b/Project/app/models/blog_comment.rb new file mode 100644 index 0000000..d37049d --- /dev/null +++ b/Project/app/models/blog_comment.rb @@ -0,0 +1,3 @@ +class BlogComment < ActiveRecord::Base + belongs_to :blog +end diff --git a/Project/app/views/blogs/show.html.erb b/Project/app/views/blogs/show.html.erb index ca65b2c..b415b7e 100644 --- a/Project/app/views/blogs/show.html.erb +++ b/Project/app/views/blogs/show.html.erb @@ -1,5 +1,6 @@ - +# This view is to show the comments on case study +# Author Bergitte

Title: <%= @blog.title %> @@ -10,5 +11,31 @@ <%= @blog.content %>

- -<%= link_to 'Back', blogs_path %> +

Comments

+<% @blog.blogs_Comments.each do |blog_Comment| %> +

+ Commenter: + <%= blogs_comments.commenter %> +

+ +

+ Blogcomment: + <%= blogs_comments.body %> +

+<% end %> + +

Add a comment:

+<%= form_for([@blog, @blog.blogs_comments.build]) do |f| %> +

+ <%= f.label :user_id %>
+ <%= f.text_field :user_id %> +

+

+ <%= f.label :body %>
+ <%= f.text_area :body %> +

+

+ <%= f.submit %> +

+<% end %> + <%= link_to 'Back', blogs_path %> diff --git a/Project/config/routes.rb b/Project/config/routes.rb index 31308f8..9b3988d 100644 --- a/Project/config/routes.rb +++ b/Project/config/routes.rb @@ -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' @@ -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. diff --git a/Project/db/migrate/20150429133753_create_blog_comments.rb b/Project/db/migrate/20150429133753_create_blog_comments.rb new file mode 100644 index 0000000..70cf193 --- /dev/null +++ b/Project/db/migrate/20150429133753_create_blog_comments.rb @@ -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 diff --git a/Project/db/schema.rb b/Project/db/schema.rb index 0563a7e..26feeb6 100644 --- a/Project/db/schema.rb +++ b/Project/db/schema.rb @@ -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" diff --git a/Project/db/seeds.rb b/Project/db/seeds.rb index f58fe9c..16c73c3 100644 --- a/Project/db/seeds.rb +++ b/Project/db/seeds.rb @@ -11,7 +11,6 @@ user.save! - admin_user1 = User.new( :email => 'nageeb94@hotmail.com', :password => '12345678') admin_user1.admin = true admin_user1.approved = true @@ -29,3 +28,4 @@ ideator_user1.is_Ideator = true ideator_user1.approved = true ideator_user1.save! + diff --git a/Project/i2b b/Project/i2b index 279b9ac..b2afbf2 160000 --- a/Project/i2b +++ b/Project/i2b @@ -1 +1 @@ -Subproject commit 279b9acaf7fcbb8fbbff07fe1a3a04cf05e593ac +Subproject commit b2afbf2e0ea02abb40bc49da3f1a31cd10ceae77 diff --git a/Project/test/controllers/b_log_comment_controller_test.rb b/Project/test/controllers/b_log_comment_controller_test.rb new file mode 100644 index 0000000..8c9e73c --- /dev/null +++ b/Project/test/controllers/b_log_comment_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class BLogCommentControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/Project/test/controllers/blogComments_controller_test.rb b/Project/test/controllers/blogComments_controller_test.rb new file mode 100644 index 0000000..cf66f27 --- /dev/null +++ b/Project/test/controllers/blogComments_controller_test.rb @@ -0,0 +1,2 @@ + +In progess \ No newline at end of file diff --git a/Project/test/controllers/comment_controller_test.rb b/Project/test/controllers/comment_controller_test.rb new file mode 100644 index 0000000..d9ad156 --- /dev/null +++ b/Project/test/controllers/comment_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/Project/test/fixtures/blog_comments.yml b/Project/test/fixtures/blog_comments.yml new file mode 100644 index 0000000..d4e9d04 --- /dev/null +++ b/Project/test/fixtures/blog_comments.yml @@ -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 diff --git a/Project/test/models/blog_comment_test.rb b/Project/test/models/blog_comment_test.rb new file mode 100644 index 0000000..f3faa7b --- /dev/null +++ b/Project/test/models/blog_comment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class BlogCommentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end