From 6b579660358ffe319f6a16c75da342c03cb4da4f Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Wed, 15 Oct 2014 17:56:17 -0500 Subject: [PATCH 01/51] working table order (in response) --- app/views/responses/_form.html.erb | 2 +- app/views/responses/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/responses/_form.html.erb b/app/views/responses/_form.html.erb index db3030a..00ef079 100644 --- a/app/views/responses/_form.html.erb +++ b/app/views/responses/_form.html.erb @@ -19,7 +19,7 @@ <%= f.submit %> <%=f.hidden_field :response_id, :value => 456 %> - <%=f.hidden_field :creator_id, :value => 123 %> + <%=f.hidden_field :creator_id, :value => 100 %> <%=f.hidden_field :response_score, :value => 0 %> <%=f.hidden_field :timestamp, :value => DateTime.now %> <%=f.hidden_field :q_response_id, :value => params[:question_id] %> diff --git a/app/views/responses/index.html.erb b/app/views/responses/index.html.erb index 278ef14..3d5d601 100644 --- a/app/views/responses/index.html.erb +++ b/app/views/responses/index.html.erb @@ -15,7 +15,7 @@ - <% @responses.each do |response| %> + <% @responses.order('timestamp').reverse_order().take(3).each do |response| %> <%= response.response_id %> <%= response.q_response_id %> From 1e6fc0fbcad1f82612a5ef2202f6df789c9fb0af Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Mon, 20 Oct 2014 18:38:01 -0500 Subject: [PATCH 02/51] users added --- app/assets/javascripts/answers.js.coffee | 3 + app/assets/javascripts/hackers.js.coffee | 3 + app/assets/stylesheets/answers.css.scss | 3 + app/assets/stylesheets/hackers.css.scss | 3 + app/controllers/answers_controller.rb | 78 +++++++++++++++++++ app/controllers/hackers_controller.rb | 74 ++++++++++++++++++ app/controllers/questions_controller.rb | 1 + app/helpers/answers_helper.rb | 2 + app/helpers/hackers_helper.rb | 2 + app/models/answer.rb | 2 + app/models/hacker.rb | 2 + app/views/answers/_form.html.erb | 26 +++++++ app/views/answers/edit.html.erb | 6 ++ app/views/answers/index.html.erb | 36 +++++++++ app/views/answers/index.json.jbuilder | 4 + app/views/answers/new.html.erb | 5 ++ app/views/answers/show.html.erb | 34 ++++++++ app/views/answers/show.json.jbuilder | 1 + app/views/hackers/_form.html.erb | 41 ++++++++++ app/views/hackers/edit.html.erb | 6 ++ app/views/hackers/index.html.erb | 37 +++++++++ app/views/hackers/index.json.jbuilder | 4 + app/views/hackers/new.html.erb | 5 ++ app/views/hackers/show.html.erb | 34 ++++++++ app/views/hackers/show.json.jbuilder | 1 + app/views/questions/index.html.erb | 6 +- app/views/responses/index.html.erb | 3 +- config/routes.rb | 4 + db/migrate/20141013185823_create_questions.rb | 2 + db/migrate/20141020220453_create_answers.rb | 14 ++++ db/migrate/20141020233116_create_hackers.rb | 14 ++++ db/schema.rb | 24 +++++- test/controllers/answers_controller_test.rb | 49 ++++++++++++ test/controllers/hackers_controller_test.rb | 49 ++++++++++++ test/fixtures/answers.yml | 17 ++++ test/fixtures/hackers.yml | 17 ++++ test/helpers/answers_helper_test.rb | 4 + test/helpers/hackers_helper_test.rb | 4 + test/models/answer_test.rb | 7 ++ test/models/hacker_test.rb | 7 ++ 40 files changed, 629 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/answers.js.coffee create mode 100644 app/assets/javascripts/hackers.js.coffee create mode 100644 app/assets/stylesheets/answers.css.scss create mode 100644 app/assets/stylesheets/hackers.css.scss create mode 100644 app/controllers/answers_controller.rb create mode 100644 app/controllers/hackers_controller.rb create mode 100644 app/helpers/answers_helper.rb create mode 100644 app/helpers/hackers_helper.rb create mode 100644 app/models/answer.rb create mode 100644 app/models/hacker.rb create mode 100644 app/views/answers/_form.html.erb create mode 100644 app/views/answers/edit.html.erb create mode 100644 app/views/answers/index.html.erb create mode 100644 app/views/answers/index.json.jbuilder create mode 100644 app/views/answers/new.html.erb create mode 100644 app/views/answers/show.html.erb create mode 100644 app/views/answers/show.json.jbuilder create mode 100644 app/views/hackers/_form.html.erb create mode 100644 app/views/hackers/edit.html.erb create mode 100644 app/views/hackers/index.html.erb create mode 100644 app/views/hackers/index.json.jbuilder create mode 100644 app/views/hackers/new.html.erb create mode 100644 app/views/hackers/show.html.erb create mode 100644 app/views/hackers/show.json.jbuilder create mode 100644 db/migrate/20141020220453_create_answers.rb create mode 100644 db/migrate/20141020233116_create_hackers.rb create mode 100644 test/controllers/answers_controller_test.rb create mode 100644 test/controllers/hackers_controller_test.rb create mode 100644 test/fixtures/answers.yml create mode 100644 test/fixtures/hackers.yml create mode 100644 test/helpers/answers_helper_test.rb create mode 100644 test/helpers/hackers_helper_test.rb create mode 100644 test/models/answer_test.rb create mode 100644 test/models/hacker_test.rb diff --git a/app/assets/javascripts/answers.js.coffee b/app/assets/javascripts/answers.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/answers.js.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/app/assets/javascripts/hackers.js.coffee b/app/assets/javascripts/hackers.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/hackers.js.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/app/assets/stylesheets/answers.css.scss b/app/assets/stylesheets/answers.css.scss new file mode 100644 index 0000000..24dc3ae --- /dev/null +++ b/app/assets/stylesheets/answers.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Answers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/hackers.css.scss b/app/assets/stylesheets/hackers.css.scss new file mode 100644 index 0000000..3a13f75 --- /dev/null +++ b/app/assets/stylesheets/hackers.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Hackers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb new file mode 100644 index 0000000..d2e7dc1 --- /dev/null +++ b/app/controllers/answers_controller.rb @@ -0,0 +1,78 @@ +class AnswersController < ApplicationController + before_action :set_answer, only: [:show, :edit, :update, :destroy] + + # GET /answers + # GET /answers.json + def index + @answers = Answer.all + end + + # GET /answers/1 + # GET /answers/1.json + def show + end + + # GET /answers/new + def new + @answer = Answer.new + end + + # GET /answers/1/edit + def edit + end + + # POST /answers + # POST /answers.json + def create + @answer = Answer.new(answer_params) + + respond_to do |format| + if @answer.save + format.html { redirect_to @answer, notice: 'Answer was successfully created.' } + format.json { render :show, status: :created, location: @answer } + else + format.html { render :new } + format.json { render json: @answer.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /answers/1 + # PATCH/PUT /answers/1.json + def update + respond_to do |format| + if @answer.update(answer_params) + format.html { redirect_to @answer, notice: 'Answer was successfully updated.' } + format.json { render :show, status: :ok, location: @answer } + else + format.html { render :edit } + format.json { render json: @answer.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /answers/1 + # DELETE /answers/1.json + def destroy + @answer.destroy + respond_to do |format| + format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_answer + @answer = Answer.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def answer_params + params.require(:answer).permit(:answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp) + end + + def answer + @answer.response_score=1 + end +end diff --git a/app/controllers/hackers_controller.rb b/app/controllers/hackers_controller.rb new file mode 100644 index 0000000..a9dfef5 --- /dev/null +++ b/app/controllers/hackers_controller.rb @@ -0,0 +1,74 @@ +class HackersController < ApplicationController + before_action :set_hacker, only: [:show, :edit, :update, :destroy] + + # GET /hackers + # GET /hackers.json + def index + @hackers = Hacker.all + end + + # GET /hackers/1 + # GET /hackers/1.json + def show + end + + # GET /hackers/new + def new + @hacker = Hacker.new + end + + # GET /hackers/1/edit + def edit + end + + # POST /hackers + # POST /hackers.json + def create + @hacker = Hacker.new(hacker_params) + + respond_to do |format| + if @hacker.save + format.html { redirect_to @hacker, notice: 'Hacker was successfully created.' } + format.json { render :show, status: :created, location: @hacker } + else + format.html { render :new } + format.json { render json: @hacker.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /hackers/1 + # PATCH/PUT /hackers/1.json + def update + respond_to do |format| + if @hacker.update(hacker_params) + format.html { redirect_to @hacker, notice: 'Hacker was successfully updated.' } + format.json { render :show, status: :ok, location: @hacker } + else + format.html { render :edit } + format.json { render json: @hacker.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /hackers/1 + # DELETE /hackers/1.json + def destroy + @hacker.destroy + respond_to do |format| + format.html { redirect_to hackers_url, notice: 'Hacker was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_hacker + @hacker = Hacker.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def hacker_params + params.require(:hacker).permit(:username, :password, :first_name, :last_name, :score, :type) + end +end diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 3e9d951..6c64d3a 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -71,4 +71,5 @@ def set_question def question_params params.require(:question).permit(:question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp) end + end diff --git a/app/helpers/answers_helper.rb b/app/helpers/answers_helper.rb new file mode 100644 index 0000000..b7cdb29 --- /dev/null +++ b/app/helpers/answers_helper.rb @@ -0,0 +1,2 @@ +module AnswersHelper +end diff --git a/app/helpers/hackers_helper.rb b/app/helpers/hackers_helper.rb new file mode 100644 index 0000000..885a3da --- /dev/null +++ b/app/helpers/hackers_helper.rb @@ -0,0 +1,2 @@ +module HackersHelper +end diff --git a/app/models/answer.rb b/app/models/answer.rb new file mode 100644 index 0000000..ec007f9 --- /dev/null +++ b/app/models/answer.rb @@ -0,0 +1,2 @@ +class Answer < ActiveRecord::Base +end diff --git a/app/models/hacker.rb b/app/models/hacker.rb new file mode 100644 index 0000000..c760509 --- /dev/null +++ b/app/models/hacker.rb @@ -0,0 +1,2 @@ +class Hacker < ActiveRecord::Base +end diff --git a/app/views/answers/_form.html.erb b/app/views/answers/_form.html.erb new file mode 100644 index 0000000..78c7de2 --- /dev/null +++ b/app/views/answers/_form.html.erb @@ -0,0 +1,26 @@ +<%= form_for(@answer) do |f| %> + <% if @answer.errors.any? %> +
+

<%= pluralize(@answer.errors.count, "error") %> prohibited this answer from being saved:

+ +
    + <% @answer.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :content %>
+ <%= f.text_area :content, size: '50x10' %> +
+
+ <%= f.submit %> +
+ <%=f.hidden_field :response_id, :value => 456 %> + <%=f.hidden_field :creator_id, :value => 100 %> + <%=f.hidden_field :response_score, :value => 0 %> + <%=f.hidden_field :timestamp, :value => DateTime.now %> + <%=f.hidden_field :q_response_id, :value => params[:question_id] %> +<% end %> diff --git a/app/views/answers/edit.html.erb b/app/views/answers/edit.html.erb new file mode 100644 index 0000000..92f7d3f --- /dev/null +++ b/app/views/answers/edit.html.erb @@ -0,0 +1,6 @@ +

Editing answer

+ +<%= render 'form' %> + +<%= link_to 'Show', @answer %> | +<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb new file mode 100644 index 0000000..0bd41ec --- /dev/null +++ b/app/views/answers/index.html.erb @@ -0,0 +1,36 @@ +

Listing answers

+ + + + + + + + + + + + + + + + <% @answers.each do |answer| %> + + + + + + + + + + + + + <% end %> + +
AnswerQ responseCreatorResponse scoreContentTimestamp
<%= answer.id %><%= answer.q_response_id %><%= answer.creator_id %><%= answer.response_score %><%= answer.content %><%= answer.timestamp %><%= link_to 'Show', answer %><%= link_to 'Edit', edit_answer_path(answer) %><%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %>
+ +
+ +<%= link_to 'New Answer', new_answer_path %> diff --git a/app/views/answers/index.json.jbuilder b/app/views/answers/index.json.jbuilder new file mode 100644 index 0000000..8403297 --- /dev/null +++ b/app/views/answers/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@answers) do |answer| + json.extract! answer, :id, :answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp + json.url answer_url(answer, format: :json) +end diff --git a/app/views/answers/new.html.erb b/app/views/answers/new.html.erb new file mode 100644 index 0000000..20757c4 --- /dev/null +++ b/app/views/answers/new.html.erb @@ -0,0 +1,5 @@ +

New answer

+ +<%= render 'form' %> + +<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/show.html.erb b/app/views/answers/show.html.erb new file mode 100644 index 0000000..57a0a90 --- /dev/null +++ b/app/views/answers/show.html.erb @@ -0,0 +1,34 @@ +

<%= notice %>

+ +

+ Answer: + <%= @answer.answer_id %> +

+ +

+ Q response: + <%= @answer.q_response_id %> +

+ +

+ Creator: + <%= @answer.creator_id %> +

+ +

+ Response score: + <%= @answer.response_score %> +

+ +

+ Content: + <%= @answer.content %> +

+ +

+ Timestamp: + <%= @answer.timestamp %> +

+ +<%= link_to 'Edit', edit_answer_path(@answer) %> | +<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/show.json.jbuilder b/app/views/answers/show.json.jbuilder new file mode 100644 index 0000000..0d70158 --- /dev/null +++ b/app/views/answers/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @answer, :id, :answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp, :created_at, :updated_at diff --git a/app/views/hackers/_form.html.erb b/app/views/hackers/_form.html.erb new file mode 100644 index 0000000..372d2ac --- /dev/null +++ b/app/views/hackers/_form.html.erb @@ -0,0 +1,41 @@ +<%= form_for(@hacker) do |f| %> + <% if @hacker.errors.any? %> +
+

<%= pluralize(@hacker.errors.count, "error") %> prohibited this hacker from being saved:

+ +
    + <% @hacker.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :username %>
+ <%= f.text_field :username %> +
+
+ <%= f.label :password %>
+ <%= f.text_field :password %> +
+
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name %> +
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name %> +
+
+ <%= f.label :score %>
+ <%= f.number_field :score %> +
+
+ <%= f.label :type %>
+ <%= f.number_field :type %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/hackers/edit.html.erb b/app/views/hackers/edit.html.erb new file mode 100644 index 0000000..b585a65 --- /dev/null +++ b/app/views/hackers/edit.html.erb @@ -0,0 +1,6 @@ +

Editing hacker

+ +<%= render 'form' %> + +<%= link_to 'Show', @hacker %> | +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/index.html.erb b/app/views/hackers/index.html.erb new file mode 100644 index 0000000..7f7918b --- /dev/null +++ b/app/views/hackers/index.html.erb @@ -0,0 +1,37 @@ +

Listing hackers

+ + + + + + + + + + + + + + + + + <% @hackers.each do |hacker| %> + + + + + + + + + + + + + <% end %> + +
idUsernamePasswordFirst nameLast nameScoreType
<%= hacker.id %><%= hacker.username %><%= hacker.password %><%= hacker.first_name %><%= hacker.last_name %><%= hacker.score %><%= hacker.type %><%= link_to 'Show', hacker %><%= link_to 'Edit', edit_hacker_path(hacker) %><%= link_to 'Destroy', hacker, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Hacker', new_hacker_path %> diff --git a/app/views/hackers/index.json.jbuilder b/app/views/hackers/index.json.jbuilder new file mode 100644 index 0000000..e13c550 --- /dev/null +++ b/app/views/hackers/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@hackers) do |hacker| + json.extract! hacker, :id, :username, :password, :first_name, :last_name, :score, :type + json.url hacker_url(hacker, format: :json) +end diff --git a/app/views/hackers/new.html.erb b/app/views/hackers/new.html.erb new file mode 100644 index 0000000..e141b1f --- /dev/null +++ b/app/views/hackers/new.html.erb @@ -0,0 +1,5 @@ +

New hacker

+ +<%= render 'form' %> + +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/show.html.erb b/app/views/hackers/show.html.erb new file mode 100644 index 0000000..32e9748 --- /dev/null +++ b/app/views/hackers/show.html.erb @@ -0,0 +1,34 @@ +

<%= notice %>

+ +

+ Username: + <%= @hacker.username %> +

+ +

+ Password: + <%= @hacker.password %> +

+ +

+ First name: + <%= @hacker.first_name %> +

+ +

+ Last name: + <%= @hacker.last_name %> +

+ +

+ Score: + <%= @hacker.score %> +

+ +

+ Type: + <%= @hacker.type %> +

+ +<%= link_to 'Edit', edit_hacker_path(@hacker) %> | +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/show.json.jbuilder b/app/views/hackers/show.json.jbuilder new file mode 100644 index 0000000..b71b64b --- /dev/null +++ b/app/views/hackers/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @hacker, :id, :username, :password, :first_name, :last_name, :score, :type, :created_at, :updated_at diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 9f35791..7376c9c 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -68,7 +68,7 @@ <% @questions.each do |question| %> - <%= question.question_id %> + <%= question.id %> <%= question.creator_id %> <%= question.title %> <%= question.content %> @@ -79,13 +79,15 @@ <%= link_to 'Show', question %> <%= link_to 'Edit', edit_question_path(question) %> <%= link_to 'Destroy', question, method: :delete, data: { confirm: 'Are you sure?' } %> - <%= link_to 'Respond', new_response_path(:question_id => question.question_id) %> + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> <% end %>
+ + <%= link_to 'New Question', new_question_path %> diff --git a/app/views/responses/index.html.erb b/app/views/responses/index.html.erb index 3d5d601..0213966 100644 --- a/app/views/responses/index.html.erb +++ b/app/views/responses/index.html.erb @@ -17,7 +17,7 @@ <% @responses.order('timestamp').reverse_order().take(3).each do |response| %> - <%= response.response_id %> + <%= response.id %> <%= response.q_response_id %> <%= response.r_response_id %> <%= response.creator_id %> @@ -27,7 +27,6 @@ <%= link_to 'Show', response %> <%= link_to 'Edit', edit_response_path(response) %> <%= link_to 'Destroy', response, method: :delete, data: { confirm: 'Are you sure?' } %> - <%= link_to 'Respond', new_response_path(:question_id => response.q_response_id, :response_id => response.response_id) %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 7ee7ed2..18b08da 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,8 @@ Rails.application.routes.draw do + resources :hackers + + resources :answers + root 'questions#index' resources :responses diff --git a/db/migrate/20141013185823_create_questions.rb b/db/migrate/20141013185823_create_questions.rb index b24e487..ab88d5e 100644 --- a/db/migrate/20141013185823_create_questions.rb +++ b/db/migrate/20141013185823_create_questions.rb @@ -13,4 +13,6 @@ def change t.timestamps end end + + end diff --git a/db/migrate/20141020220453_create_answers.rb b/db/migrate/20141020220453_create_answers.rb new file mode 100644 index 0000000..2b221cf --- /dev/null +++ b/db/migrate/20141020220453_create_answers.rb @@ -0,0 +1,14 @@ +class CreateAnswers < ActiveRecord::Migration + def change + create_table :answers do |t| + t.integer :answer_id + t.integer :q_response_id + t.integer :creator_id + t.integer :response_score + t.text :content + t.datetime :timestamp + + t.timestamps + end + end +end diff --git a/db/migrate/20141020233116_create_hackers.rb b/db/migrate/20141020233116_create_hackers.rb new file mode 100644 index 0000000..4cd367a --- /dev/null +++ b/db/migrate/20141020233116_create_hackers.rb @@ -0,0 +1,14 @@ +class CreateHackers < ActiveRecord::Migration + def change + create_table :hackers do |t| + t.string :username + t.string :password + t.string :first_name + t.string :last_name + t.integer :score + t.integer :type + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index ee1820c..261e370 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,29 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20141013235253) do +ActiveRecord::Schema.define(version: 20141020233116) do + + create_table "answers", force: true do |t| + t.integer "answer_id" + t.integer "q_response_id" + t.integer "creator_id" + t.integer "response_score" + t.text "content" + t.datetime "timestamp" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "hackers", force: true do |t| + t.string "username" + t.string "password" + t.string "first_name" + t.string "last_name" + t.integer "score" + t.integer "type" + t.datetime "created_at" + t.datetime "updated_at" + end create_table "messages", force: true do |t| t.integer "message_id" diff --git a/test/controllers/answers_controller_test.rb b/test/controllers/answers_controller_test.rb new file mode 100644 index 0000000..7d9381c --- /dev/null +++ b/test/controllers/answers_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class AnswersControllerTest < ActionController::TestCase + setup do + @answer = answers(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:answers) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create answer" do + assert_difference('Answer.count') do + post :create, answer: { answer_id: @answer.answer_id, content: @answer.content, creator_id: @answer.creator_id, q_response_id: @answer.q_response_id, response_score: @answer.response_score, timestamp: @answer.timestamp } + end + + assert_redirected_to answer_path(assigns(:answer)) + end + + test "should show answer" do + get :show, id: @answer + assert_response :success + end + + test "should get edit" do + get :edit, id: @answer + assert_response :success + end + + test "should update answer" do + patch :update, id: @answer, answer: { answer_id: @answer.answer_id, content: @answer.content, creator_id: @answer.creator_id, q_response_id: @answer.q_response_id, response_score: @answer.response_score, timestamp: @answer.timestamp } + assert_redirected_to answer_path(assigns(:answer)) + end + + test "should destroy answer" do + assert_difference('Answer.count', -1) do + delete :destroy, id: @answer + end + + assert_redirected_to answers_path + end +end diff --git a/test/controllers/hackers_controller_test.rb b/test/controllers/hackers_controller_test.rb new file mode 100644 index 0000000..ec8926b --- /dev/null +++ b/test/controllers/hackers_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class HackersControllerTest < ActionController::TestCase + setup do + @hacker = hackers(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:hackers) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create hacker" do + assert_difference('Hacker.count') do + post :create, hacker: { first_name: @hacker.first_name, last_name: @hacker.last_name, password: @hacker.password, score: @hacker.score, type: @hacker.type, username: @hacker.username } + end + + assert_redirected_to hacker_path(assigns(:hacker)) + end + + test "should show hacker" do + get :show, id: @hacker + assert_response :success + end + + test "should get edit" do + get :edit, id: @hacker + assert_response :success + end + + test "should update hacker" do + patch :update, id: @hacker, hacker: { first_name: @hacker.first_name, last_name: @hacker.last_name, password: @hacker.password, score: @hacker.score, type: @hacker.type, username: @hacker.username } + assert_redirected_to hacker_path(assigns(:hacker)) + end + + test "should destroy hacker" do + assert_difference('Hacker.count', -1) do + delete :destroy, id: @hacker + end + + assert_redirected_to hackers_path + end +end diff --git a/test/fixtures/answers.yml b/test/fixtures/answers.yml new file mode 100644 index 0000000..dabb2ee --- /dev/null +++ b/test/fixtures/answers.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + answer_id: 1 + q_response_id: 1 + creator_id: 1 + response_score: 1 + content: MyText + timestamp: 2014-10-20 17:04:53 + +two: + answer_id: 1 + q_response_id: 1 + creator_id: 1 + response_score: 1 + content: MyText + timestamp: 2014-10-20 17:04:53 diff --git a/test/fixtures/hackers.yml b/test/fixtures/hackers.yml new file mode 100644 index 0000000..67c2a75 --- /dev/null +++ b/test/fixtures/hackers.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + username: MyString + password: MyString + first_name: MyString + last_name: MyString + score: 1 + type: 1 + +two: + username: MyString + password: MyString + first_name: MyString + last_name: MyString + score: 1 + type: 1 diff --git a/test/helpers/answers_helper_test.rb b/test/helpers/answers_helper_test.rb new file mode 100644 index 0000000..a044015 --- /dev/null +++ b/test/helpers/answers_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class AnswersHelperTest < ActionView::TestCase +end diff --git a/test/helpers/hackers_helper_test.rb b/test/helpers/hackers_helper_test.rb new file mode 100644 index 0000000..5389edc --- /dev/null +++ b/test/helpers/hackers_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class HackersHelperTest < ActionView::TestCase +end diff --git a/test/models/answer_test.rb b/test/models/answer_test.rb new file mode 100644 index 0000000..c0af5c3 --- /dev/null +++ b/test/models/answer_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class AnswerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/hacker_test.rb b/test/models/hacker_test.rb new file mode 100644 index 0000000..f7006d8 --- /dev/null +++ b/test/models/hacker_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class HackerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 5a5ee3b13d0ee789536c0c0f07cd1080b9c83046 Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Mon, 10 Nov 2014 17:19:13 -0600 Subject: [PATCH 03/51] bad --- app/assets/images/.keep | 0 app/assets/javascripts/answers.js.coffee | 3 - app/assets/javascripts/application.js | 16 ---- app/assets/javascripts/hackers.js.coffee | 3 - app/assets/javascripts/messages.js.coffee | 3 - app/assets/javascripts/questions.js.coffee | 3 - app/assets/javascripts/responses.js.coffee | 3 - app/assets/javascripts/users.js.coffee | 3 - app/assets/stylesheets/answers.css.scss | 3 - app/assets/stylesheets/application.css | 15 ---- app/assets/stylesheets/hackers.css.scss | 3 - app/assets/stylesheets/messages.css.scss | 3 - app/assets/stylesheets/questions.css.scss | 3 - app/assets/stylesheets/responses.css.scss | 3 - app/assets/stylesheets/scaffolds.css.scss | 69 --------------- app/assets/stylesheets/users.css.scss | 3 - app/controllers/answers_controller.rb | 78 ----------------- app/controllers/application_controller.rb | 5 -- app/controllers/concerns/.keep | 0 app/controllers/hackers_controller.rb | 74 ----------------- app/controllers/messages_controller.rb | 74 ----------------- app/controllers/questions_controller.rb | 75 ----------------- app/controllers/responses_controller.rb | 77 ----------------- app/controllers/users_controller.rb | 74 ----------------- app/helpers/answers_helper.rb | 2 - app/helpers/application_helper.rb | 2 - app/helpers/hackers_helper.rb | 2 - app/helpers/messages_helper.rb | 2 - app/helpers/questions_helper.rb | 2 - app/helpers/responses_helper.rb | 2 - app/helpers/users_helper.rb | 2 - app/mailers/.keep | 0 app/models/.keep | 0 app/models/answer.rb | 2 - app/models/concerns/.keep | 0 app/models/hacker.rb | 2 - app/models/message.rb | 2 - app/models/question.rb | 3 - app/models/question2.rb | 2 - app/models/response.rb | 2 - app/models/user.rb | 2 - app/views/answers/_form.html.erb | 26 ------ app/views/answers/edit.html.erb | 6 -- app/views/answers/index.html.erb | 36 -------- app/views/answers/index.json.jbuilder | 4 - app/views/answers/new.html.erb | 5 -- app/views/answers/show.html.erb | 34 -------- app/views/answers/show.json.jbuilder | 1 - app/views/hackers/_form.html.erb | 41 --------- app/views/hackers/edit.html.erb | 6 -- app/views/hackers/index.html.erb | 37 --------- app/views/hackers/index.json.jbuilder | 4 - app/views/hackers/new.html.erb | 5 -- app/views/hackers/show.html.erb | 34 -------- app/views/hackers/show.json.jbuilder | 1 - app/views/home/index.html.erb | 46 ---------- app/views/layouts/application.html.erb | 14 ---- app/views/messages/_form.html.erb | 41 --------- app/views/messages/edit.html.erb | 6 -- app/views/messages/index.html.erb | 35 -------- app/views/messages/index.json.jbuilder | 4 - app/views/messages/new.html.erb | 5 -- app/views/messages/show.html.erb | 34 -------- app/views/messages/show.json.jbuilder | 1 - app/views/questions/_form.html.erb | 26 ------ app/views/questions/edit.html.erb | 6 -- app/views/questions/index.html.erb | 97 ---------------------- app/views/questions/index.json.jbuilder | 4 - app/views/questions/new.html.erb | 5 -- app/views/questions/show.html.erb | 44 ---------- app/views/questions/show.json.jbuilder | 1 - app/views/responses/_form.html.erb | 27 ------ app/views/responses/edit.html.erb | 6 -- app/views/responses/index.html.erb | 37 --------- app/views/responses/index.json.jbuilder | 4 - app/views/responses/new.html.erb | 5 -- app/views/responses/show.html.erb | 39 --------- app/views/responses/show.json.jbuilder | 1 - app/views/users/_form.html.erb | 45 ---------- app/views/users/edit.html.erb | 6 -- app/views/users/index.html.erb | 37 --------- app/views/users/index.json.jbuilder | 4 - app/views/users/new.html.erb | 5 -- app/views/users/show.html.erb | 39 --------- app/views/users/show.json.jbuilder | 1 - bin/bundle | 3 - bin/rails | 4 - bin/rake | 4 - 88 files changed, 1498 deletions(-) delete mode 100644 app/assets/images/.keep delete mode 100644 app/assets/javascripts/answers.js.coffee delete mode 100644 app/assets/javascripts/application.js delete mode 100644 app/assets/javascripts/hackers.js.coffee delete mode 100644 app/assets/javascripts/messages.js.coffee delete mode 100644 app/assets/javascripts/questions.js.coffee delete mode 100644 app/assets/javascripts/responses.js.coffee delete mode 100644 app/assets/javascripts/users.js.coffee delete mode 100644 app/assets/stylesheets/answers.css.scss delete mode 100644 app/assets/stylesheets/application.css delete mode 100644 app/assets/stylesheets/hackers.css.scss delete mode 100644 app/assets/stylesheets/messages.css.scss delete mode 100644 app/assets/stylesheets/questions.css.scss delete mode 100644 app/assets/stylesheets/responses.css.scss delete mode 100644 app/assets/stylesheets/scaffolds.css.scss delete mode 100644 app/assets/stylesheets/users.css.scss delete mode 100644 app/controllers/answers_controller.rb delete mode 100644 app/controllers/application_controller.rb delete mode 100644 app/controllers/concerns/.keep delete mode 100644 app/controllers/hackers_controller.rb delete mode 100644 app/controllers/messages_controller.rb delete mode 100644 app/controllers/questions_controller.rb delete mode 100644 app/controllers/responses_controller.rb delete mode 100644 app/controllers/users_controller.rb delete mode 100644 app/helpers/answers_helper.rb delete mode 100644 app/helpers/application_helper.rb delete mode 100644 app/helpers/hackers_helper.rb delete mode 100644 app/helpers/messages_helper.rb delete mode 100644 app/helpers/questions_helper.rb delete mode 100644 app/helpers/responses_helper.rb delete mode 100644 app/helpers/users_helper.rb delete mode 100644 app/mailers/.keep delete mode 100644 app/models/.keep delete mode 100644 app/models/answer.rb delete mode 100644 app/models/concerns/.keep delete mode 100644 app/models/hacker.rb delete mode 100644 app/models/message.rb delete mode 100644 app/models/question.rb delete mode 100644 app/models/question2.rb delete mode 100644 app/models/response.rb delete mode 100644 app/models/user.rb delete mode 100644 app/views/answers/_form.html.erb delete mode 100644 app/views/answers/edit.html.erb delete mode 100644 app/views/answers/index.html.erb delete mode 100644 app/views/answers/index.json.jbuilder delete mode 100644 app/views/answers/new.html.erb delete mode 100644 app/views/answers/show.html.erb delete mode 100644 app/views/answers/show.json.jbuilder delete mode 100644 app/views/hackers/_form.html.erb delete mode 100644 app/views/hackers/edit.html.erb delete mode 100644 app/views/hackers/index.html.erb delete mode 100644 app/views/hackers/index.json.jbuilder delete mode 100644 app/views/hackers/new.html.erb delete mode 100644 app/views/hackers/show.html.erb delete mode 100644 app/views/hackers/show.json.jbuilder delete mode 100644 app/views/home/index.html.erb delete mode 100644 app/views/layouts/application.html.erb delete mode 100644 app/views/messages/_form.html.erb delete mode 100644 app/views/messages/edit.html.erb delete mode 100644 app/views/messages/index.html.erb delete mode 100644 app/views/messages/index.json.jbuilder delete mode 100644 app/views/messages/new.html.erb delete mode 100644 app/views/messages/show.html.erb delete mode 100644 app/views/messages/show.json.jbuilder delete mode 100644 app/views/questions/_form.html.erb delete mode 100644 app/views/questions/edit.html.erb delete mode 100644 app/views/questions/index.html.erb delete mode 100644 app/views/questions/index.json.jbuilder delete mode 100644 app/views/questions/new.html.erb delete mode 100644 app/views/questions/show.html.erb delete mode 100644 app/views/questions/show.json.jbuilder delete mode 100644 app/views/responses/_form.html.erb delete mode 100644 app/views/responses/edit.html.erb delete mode 100644 app/views/responses/index.html.erb delete mode 100644 app/views/responses/index.json.jbuilder delete mode 100644 app/views/responses/new.html.erb delete mode 100644 app/views/responses/show.html.erb delete mode 100644 app/views/responses/show.json.jbuilder delete mode 100644 app/views/users/_form.html.erb delete mode 100644 app/views/users/edit.html.erb delete mode 100644 app/views/users/index.html.erb delete mode 100644 app/views/users/index.json.jbuilder delete mode 100644 app/views/users/new.html.erb delete mode 100644 app/views/users/show.html.erb delete mode 100644 app/views/users/show.json.jbuilder delete mode 100644 bin/bundle delete mode 100644 bin/rails delete mode 100644 bin/rake diff --git a/app/assets/images/.keep b/app/assets/images/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/assets/javascripts/answers.js.coffee b/app/assets/javascripts/answers.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/answers.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# 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/app/assets/javascripts/application.js b/app/assets/javascripts/application.js deleted file mode 100644 index d6925fa..0000000 --- a/app/assets/javascripts/application.js +++ /dev/null @@ -1,16 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. -// -// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details -// about supported directives. -// -//= require jquery -//= require jquery_ujs -//= require turbolinks -//= require_tree . diff --git a/app/assets/javascripts/hackers.js.coffee b/app/assets/javascripts/hackers.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/hackers.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# 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/app/assets/javascripts/messages.js.coffee b/app/assets/javascripts/messages.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/messages.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# 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/app/assets/javascripts/questions.js.coffee b/app/assets/javascripts/questions.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/questions.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# 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/app/assets/javascripts/responses.js.coffee b/app/assets/javascripts/responses.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/responses.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# 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/app/assets/javascripts/users.js.coffee b/app/assets/javascripts/users.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/users.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# 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/app/assets/stylesheets/answers.css.scss b/app/assets/stylesheets/answers.css.scss deleted file mode 100644 index 24dc3ae..0000000 --- a/app/assets/stylesheets/answers.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Answers controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css deleted file mode 100644 index a443db3..0000000 --- a/app/assets/stylesheets/application.css +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any styles - * defined in the other CSS/SCSS files in this directory. It is generally better to create a new - * file per style scope. - * - *= require_tree . - *= require_self - */ diff --git a/app/assets/stylesheets/hackers.css.scss b/app/assets/stylesheets/hackers.css.scss deleted file mode 100644 index 3a13f75..0000000 --- a/app/assets/stylesheets/hackers.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Hackers controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/messages.css.scss b/app/assets/stylesheets/messages.css.scss deleted file mode 100644 index 492f0fa..0000000 --- a/app/assets/stylesheets/messages.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Messages controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/questions.css.scss b/app/assets/stylesheets/questions.css.scss deleted file mode 100644 index a7cd45c..0000000 --- a/app/assets/stylesheets/questions.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Questions controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/responses.css.scss b/app/assets/stylesheets/responses.css.scss deleted file mode 100644 index ed1e1a4..0000000 --- a/app/assets/stylesheets/responses.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Responses controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss deleted file mode 100644 index 6ec6a8f..0000000 --- a/app/assets/stylesheets/scaffolds.css.scss +++ /dev/null @@ -1,69 +0,0 @@ -body { - background-color: #fff; - color: #333; - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -pre { - background-color: #eee; - padding: 10px; - font-size: 11px; -} - -a { - color: #000; - &:visited { - color: #666; - } - &:hover { - color: #fff; - background-color: #000; - } -} - -div { - &.field, &.actions { - margin-bottom: 10px; - } -} - -#notice { - color: green; -} - -.field_with_errors { - padding: 2px; - background-color: red; - display: table; -} - -#error_explanation { - width: 450px; - border: 2px solid red; - padding: 7px; - padding-bottom: 0; - margin-bottom: 20px; - background-color: #f0f0f0; - h2 { - text-align: left; - font-weight: bold; - padding: 5px 5px 5px 15px; - font-size: 12px; - margin: -7px; - margin-bottom: 0px; - background-color: #c00; - color: #fff; - } - ul li { - font-size: 12px; - list-style: square; - } -} diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss deleted file mode 100644 index 31a2eac..0000000 --- a/app/assets/stylesheets/users.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Users controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb deleted file mode 100644 index d2e7dc1..0000000 --- a/app/controllers/answers_controller.rb +++ /dev/null @@ -1,78 +0,0 @@ -class AnswersController < ApplicationController - before_action :set_answer, only: [:show, :edit, :update, :destroy] - - # GET /answers - # GET /answers.json - def index - @answers = Answer.all - end - - # GET /answers/1 - # GET /answers/1.json - def show - end - - # GET /answers/new - def new - @answer = Answer.new - end - - # GET /answers/1/edit - def edit - end - - # POST /answers - # POST /answers.json - def create - @answer = Answer.new(answer_params) - - respond_to do |format| - if @answer.save - format.html { redirect_to @answer, notice: 'Answer was successfully created.' } - format.json { render :show, status: :created, location: @answer } - else - format.html { render :new } - format.json { render json: @answer.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /answers/1 - # PATCH/PUT /answers/1.json - def update - respond_to do |format| - if @answer.update(answer_params) - format.html { redirect_to @answer, notice: 'Answer was successfully updated.' } - format.json { render :show, status: :ok, location: @answer } - else - format.html { render :edit } - format.json { render json: @answer.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /answers/1 - # DELETE /answers/1.json - def destroy - @answer.destroy - respond_to do |format| - format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_answer - @answer = Answer.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def answer_params - params.require(:answer).permit(:answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp) - end - - def answer - @answer.response_score=1 - end -end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb deleted file mode 100644 index d83690e..0000000 --- a/app/controllers/application_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ApplicationController < ActionController::Base - # Prevent CSRF attacks by raising an exception. - # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception -end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/controllers/hackers_controller.rb b/app/controllers/hackers_controller.rb deleted file mode 100644 index a9dfef5..0000000 --- a/app/controllers/hackers_controller.rb +++ /dev/null @@ -1,74 +0,0 @@ -class HackersController < ApplicationController - before_action :set_hacker, only: [:show, :edit, :update, :destroy] - - # GET /hackers - # GET /hackers.json - def index - @hackers = Hacker.all - end - - # GET /hackers/1 - # GET /hackers/1.json - def show - end - - # GET /hackers/new - def new - @hacker = Hacker.new - end - - # GET /hackers/1/edit - def edit - end - - # POST /hackers - # POST /hackers.json - def create - @hacker = Hacker.new(hacker_params) - - respond_to do |format| - if @hacker.save - format.html { redirect_to @hacker, notice: 'Hacker was successfully created.' } - format.json { render :show, status: :created, location: @hacker } - else - format.html { render :new } - format.json { render json: @hacker.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /hackers/1 - # PATCH/PUT /hackers/1.json - def update - respond_to do |format| - if @hacker.update(hacker_params) - format.html { redirect_to @hacker, notice: 'Hacker was successfully updated.' } - format.json { render :show, status: :ok, location: @hacker } - else - format.html { render :edit } - format.json { render json: @hacker.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /hackers/1 - # DELETE /hackers/1.json - def destroy - @hacker.destroy - respond_to do |format| - format.html { redirect_to hackers_url, notice: 'Hacker was successfully destroyed.' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_hacker - @hacker = Hacker.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def hacker_params - params.require(:hacker).permit(:username, :password, :first_name, :last_name, :score, :type) - end -end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb deleted file mode 100644 index be72c33..0000000 --- a/app/controllers/messages_controller.rb +++ /dev/null @@ -1,74 +0,0 @@ -class MessagesController < ApplicationController - before_action :set_message, only: [:show, :edit, :update, :destroy] - - # GET /messages - # GET /messages.json - def index - @messages = Message.all - end - - # GET /messages/1 - # GET /messages/1.json - def show - end - - # GET /messages/new - def new - @message = Message.new - end - - # GET /messages/1/edit - def edit - end - - # POST /messages - # POST /messages.json - def create - @message = Message.new(message_params) - - respond_to do |format| - if @message.save - format.html { redirect_to @message, notice: 'Message was successfully created.' } - format.json { render :show, status: :created, location: @message } - else - format.html { render :new } - format.json { render json: @message.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /messages/1 - # PATCH/PUT /messages/1.json - def update - respond_to do |format| - if @message.update(message_params) - format.html { redirect_to @message, notice: 'Message was successfully updated.' } - format.json { render :show, status: :ok, location: @message } - else - format.html { render :edit } - format.json { render json: @message.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /messages/1 - # DELETE /messages/1.json - def destroy - @message.destroy - respond_to do |format| - format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_message - @message = Message.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def message_params - params.require(:message).permit(:message_id, :sender_id, :receiver_id, :title, :content, :timestamp) - end -end diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb deleted file mode 100644 index 6c64d3a..0000000 --- a/app/controllers/questions_controller.rb +++ /dev/null @@ -1,75 +0,0 @@ -class QuestionsController < ApplicationController - before_action :set_question, only: [:show, :edit, :update, :destroy] - - # GET /questions - # GET /questions.json - def index - @questions = Question.all - end - - # GET /questions/1 - # GET /questions/1.json - def show - end - - # GET /questions/new - def new - @question = Question.new - end - - # GET /questions/1/edit - def edit - end - - # POST /questions - # POST /questions.json - def create - @question = Question.new(question_params) - - respond_to do |format| - if @question.save - format.html { redirect_to @question, notice: 'Question was successfully created.' } - format.json { render :show, status: :created, location: @question } - else - format.html { render :new } - format.json { render json: @question.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /questions/1 - # PATCH/PUT /questions/1.json - def update - respond_to do |format| - if @question.update(question_params) - format.html { redirect_to @question, notice: 'Question was successfully updated.' } - format.json { render :show, status: :ok, location: @question } - else - format.html { render :edit } - format.json { render json: @question.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /questions/1 - # DELETE /questions/1.json - def destroy - @question.destroy - respond_to do |format| - format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_question - @question = Question.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def question_params - params.require(:question).permit(:question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp) - end - -end diff --git a/app/controllers/responses_controller.rb b/app/controllers/responses_controller.rb deleted file mode 100644 index 8be4fd3..0000000 --- a/app/controllers/responses_controller.rb +++ /dev/null @@ -1,77 +0,0 @@ -class ResponsesController < ApplicationController - before_action :set_response, only: [:show, :edit, :update, :destroy] - - # GET /responses - # GET /responses.json - def index - @responses = Response.all - end - - # GET /responses/1 - # GET /responses/1.json - def show - end - - # GET /responses/new - def new - @response = Response.new - if params[:question_id] - @response.q_response_id = params[:question_id] - end - end - - # GET /responses/1/edit - def edit - end - - # POST /responses - # POST /responses.json - def create - @response = Response.new(response_params) - - respond_to do |format| - if @response.save - format.html { redirect_to @response, notice: 'Response was successfully created.' } - format.json { render :show, status: :created, location: @response } - else - format.html { render :new } - format.json { render json: @response.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /responses/1 - # PATCH/PUT /responses/1.json - def update - respond_to do |format| - if @response.update(response_params) - format.html { redirect_to @response, notice: 'Response was successfully updated.' } - format.json { render :show, status: :ok, location: @response } - else - format.html { render :edit } - format.json { render json: @response.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /responses/1 - # DELETE /responses/1.json - def destroy - @response.destroy - respond_to do |format| - format.html { redirect_to responses_url, notice: 'Response was successfully destroyed.' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_response - @response = Response.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def response_params - params.require(:response).permit(:response_id, :q_response_id, :r_response_id, :creator_id, :response_score, :content, :timestamp) - end -end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb deleted file mode 100644 index 8441ffe..0000000 --- a/app/controllers/users_controller.rb +++ /dev/null @@ -1,74 +0,0 @@ -class UsersController < ApplicationController - before_action :set_user, only: [:show, :edit, :update, :destroy] - - # GET /users - # GET /users.json - def index - @users = User.all - end - - # GET /users/1 - # GET /users/1.json - def show - end - - # GET /users/new - def new - @user = User.new - end - - # GET /users/1/edit - def edit - end - - # POST /users - # POST /users.json - def create - @user = User.new(user_params) - - respond_to do |format| - if @user.save - format.html { redirect_to @user, notice: 'User was successfully created.' } - format.json { render :show, status: :created, location: @user } - else - format.html { render :new } - format.json { render json: @user.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /users/1 - # PATCH/PUT /users/1.json - def update - respond_to do |format| - if @user.update(user_params) - format.html { redirect_to @user, notice: 'User was successfully updated.' } - format.json { render :show, status: :ok, location: @user } - else - format.html { render :edit } - format.json { render json: @user.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /users/1 - # DELETE /users/1.json - def destroy - @user.destroy - respond_to do |format| - format.html { redirect_to users_url, notice: 'User was successfully destroyed.' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_user - @user = User.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def user_params - params.require(:user).permit(:user_id, :username, :password, :first_name, :last_name, :score, :type) - end -end diff --git a/app/helpers/answers_helper.rb b/app/helpers/answers_helper.rb deleted file mode 100644 index b7cdb29..0000000 --- a/app/helpers/answers_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module AnswersHelper -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb deleted file mode 100644 index de6be79..0000000 --- a/app/helpers/application_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ApplicationHelper -end diff --git a/app/helpers/hackers_helper.rb b/app/helpers/hackers_helper.rb deleted file mode 100644 index 885a3da..0000000 --- a/app/helpers/hackers_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module HackersHelper -end diff --git a/app/helpers/messages_helper.rb b/app/helpers/messages_helper.rb deleted file mode 100644 index f1bca9f..0000000 --- a/app/helpers/messages_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module MessagesHelper -end diff --git a/app/helpers/questions_helper.rb b/app/helpers/questions_helper.rb deleted file mode 100644 index 2eaab4a..0000000 --- a/app/helpers/questions_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module QuestionsHelper -end diff --git a/app/helpers/responses_helper.rb b/app/helpers/responses_helper.rb deleted file mode 100644 index 18dadea..0000000 --- a/app/helpers/responses_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ResponsesHelper -end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb deleted file mode 100644 index 2310a24..0000000 --- a/app/helpers/users_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module UsersHelper -end diff --git a/app/mailers/.keep b/app/mailers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/models/.keep b/app/models/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/models/answer.rb b/app/models/answer.rb deleted file mode 100644 index ec007f9..0000000 --- a/app/models/answer.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Answer < ActiveRecord::Base -end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/models/hacker.rb b/app/models/hacker.rb deleted file mode 100644 index c760509..0000000 --- a/app/models/hacker.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Hacker < ActiveRecord::Base -end diff --git a/app/models/message.rb b/app/models/message.rb deleted file mode 100644 index 590e3e3..0000000 --- a/app/models/message.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Message < ActiveRecord::Base -end diff --git a/app/models/question.rb b/app/models/question.rb deleted file mode 100644 index cf6dc41..0000000 --- a/app/models/question.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Question < ActiveRecord::Base - -end diff --git a/app/models/question2.rb b/app/models/question2.rb deleted file mode 100644 index 07a670b..0000000 --- a/app/models/question2.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Question2 < ActiveRecord::Base -end diff --git a/app/models/response.rb b/app/models/response.rb deleted file mode 100644 index 28aea65..0000000 --- a/app/models/response.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Response < ActiveRecord::Base -end diff --git a/app/models/user.rb b/app/models/user.rb deleted file mode 100644 index 4a57cf0..0000000 --- a/app/models/user.rb +++ /dev/null @@ -1,2 +0,0 @@ -class User < ActiveRecord::Base -end diff --git a/app/views/answers/_form.html.erb b/app/views/answers/_form.html.erb deleted file mode 100644 index 78c7de2..0000000 --- a/app/views/answers/_form.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<%= form_for(@answer) do |f| %> - <% if @answer.errors.any? %> -
-

<%= pluralize(@answer.errors.count, "error") %> prohibited this answer from being saved:

- -
    - <% @answer.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - -
- <%= f.label :content %>
- <%= f.text_area :content, size: '50x10' %> -
-
- <%= f.submit %> -
- <%=f.hidden_field :response_id, :value => 456 %> - <%=f.hidden_field :creator_id, :value => 100 %> - <%=f.hidden_field :response_score, :value => 0 %> - <%=f.hidden_field :timestamp, :value => DateTime.now %> - <%=f.hidden_field :q_response_id, :value => params[:question_id] %> -<% end %> diff --git a/app/views/answers/edit.html.erb b/app/views/answers/edit.html.erb deleted file mode 100644 index 92f7d3f..0000000 --- a/app/views/answers/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

Editing answer

- -<%= render 'form' %> - -<%= link_to 'Show', @answer %> | -<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb deleted file mode 100644 index 0bd41ec..0000000 --- a/app/views/answers/index.html.erb +++ /dev/null @@ -1,36 +0,0 @@ -

Listing answers

- - - - - - - - - - - - - - - - <% @answers.each do |answer| %> - - - - - - - - - - - - - <% end %> - -
AnswerQ responseCreatorResponse scoreContentTimestamp
<%= answer.id %><%= answer.q_response_id %><%= answer.creator_id %><%= answer.response_score %><%= answer.content %><%= answer.timestamp %><%= link_to 'Show', answer %><%= link_to 'Edit', edit_answer_path(answer) %><%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %>
- -
- -<%= link_to 'New Answer', new_answer_path %> diff --git a/app/views/answers/index.json.jbuilder b/app/views/answers/index.json.jbuilder deleted file mode 100644 index 8403297..0000000 --- a/app/views/answers/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@answers) do |answer| - json.extract! answer, :id, :answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp - json.url answer_url(answer, format: :json) -end diff --git a/app/views/answers/new.html.erb b/app/views/answers/new.html.erb deleted file mode 100644 index 20757c4..0000000 --- a/app/views/answers/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New answer

- -<%= render 'form' %> - -<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/show.html.erb b/app/views/answers/show.html.erb deleted file mode 100644 index 57a0a90..0000000 --- a/app/views/answers/show.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -

<%= notice %>

- -

- Answer: - <%= @answer.answer_id %> -

- -

- Q response: - <%= @answer.q_response_id %> -

- -

- Creator: - <%= @answer.creator_id %> -

- -

- Response score: - <%= @answer.response_score %> -

- -

- Content: - <%= @answer.content %> -

- -

- Timestamp: - <%= @answer.timestamp %> -

- -<%= link_to 'Edit', edit_answer_path(@answer) %> | -<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/show.json.jbuilder b/app/views/answers/show.json.jbuilder deleted file mode 100644 index 0d70158..0000000 --- a/app/views/answers/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @answer, :id, :answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp, :created_at, :updated_at diff --git a/app/views/hackers/_form.html.erb b/app/views/hackers/_form.html.erb deleted file mode 100644 index 372d2ac..0000000 --- a/app/views/hackers/_form.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<%= form_for(@hacker) do |f| %> - <% if @hacker.errors.any? %> -
-

<%= pluralize(@hacker.errors.count, "error") %> prohibited this hacker from being saved:

- -
    - <% @hacker.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - -
- <%= f.label :username %>
- <%= f.text_field :username %> -
-
- <%= f.label :password %>
- <%= f.text_field :password %> -
-
- <%= f.label :first_name %>
- <%= f.text_field :first_name %> -
-
- <%= f.label :last_name %>
- <%= f.text_field :last_name %> -
-
- <%= f.label :score %>
- <%= f.number_field :score %> -
-
- <%= f.label :type %>
- <%= f.number_field :type %> -
-
- <%= f.submit %> -
-<% end %> diff --git a/app/views/hackers/edit.html.erb b/app/views/hackers/edit.html.erb deleted file mode 100644 index b585a65..0000000 --- a/app/views/hackers/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

Editing hacker

- -<%= render 'form' %> - -<%= link_to 'Show', @hacker %> | -<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/index.html.erb b/app/views/hackers/index.html.erb deleted file mode 100644 index 7f7918b..0000000 --- a/app/views/hackers/index.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -

Listing hackers

- - - - - - - - - - - - - - - - - <% @hackers.each do |hacker| %> - - - - - - - - - - - - - <% end %> - -
idUsernamePasswordFirst nameLast nameScoreType
<%= hacker.id %><%= hacker.username %><%= hacker.password %><%= hacker.first_name %><%= hacker.last_name %><%= hacker.score %><%= hacker.type %><%= link_to 'Show', hacker %><%= link_to 'Edit', edit_hacker_path(hacker) %><%= link_to 'Destroy', hacker, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Hacker', new_hacker_path %> diff --git a/app/views/hackers/index.json.jbuilder b/app/views/hackers/index.json.jbuilder deleted file mode 100644 index e13c550..0000000 --- a/app/views/hackers/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@hackers) do |hacker| - json.extract! hacker, :id, :username, :password, :first_name, :last_name, :score, :type - json.url hacker_url(hacker, format: :json) -end diff --git a/app/views/hackers/new.html.erb b/app/views/hackers/new.html.erb deleted file mode 100644 index e141b1f..0000000 --- a/app/views/hackers/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New hacker

- -<%= render 'form' %> - -<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/show.html.erb b/app/views/hackers/show.html.erb deleted file mode 100644 index 32e9748..0000000 --- a/app/views/hackers/show.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -

<%= notice %>

- -

- Username: - <%= @hacker.username %> -

- -

- Password: - <%= @hacker.password %> -

- -

- First name: - <%= @hacker.first_name %> -

- -

- Last name: - <%= @hacker.last_name %> -

- -

- Score: - <%= @hacker.score %> -

- -

- Type: - <%= @hacker.type %> -

- -<%= link_to 'Edit', edit_hacker_path(@hacker) %> | -<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/show.json.jbuilder b/app/views/hackers/show.json.jbuilder deleted file mode 100644 index b71b64b..0000000 --- a/app/views/hackers/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @hacker, :id, :username, :password, :first_name, :last_name, :score, :type, :created_at, :updated_at diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb deleted file mode 100644 index 24e379e..0000000 --- a/app/views/home/index.html.erb +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - question - - - - - - - - - - - -
-
-

question

-
- - -
- -
- -
-

- © Copyright by Seth -

-
-
- - diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index 33366d1..0000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - - Database - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> - <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> - <%= csrf_meta_tags %> - - - -<%= yield %> - - - diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb deleted file mode 100644 index 8c9baf0..0000000 --- a/app/views/messages/_form.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<%= form_for(@message) do |f| %> - <% if @message.errors.any? %> -
-

<%= pluralize(@message.errors.count, "error") %> prohibited this message from being saved:

- -
    - <% @message.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - -
- <%= f.label :message_id %>
- <%= f.number_field :message_id %> -
-
- <%= f.label :sender_id %>
- <%= f.number_field :sender_id %> -
-
- <%= f.label :receiver_id %>
- <%= f.number_field :receiver_id %> -
-
- <%= f.label :title %>
- <%= f.text_field :title %> -
-
- <%= f.label :content %>
- <%= f.text_area :content %> -
-
- <%= f.label :timestamp %>
- <%= f.datetime_select :timestamp %> -
-
- <%= f.submit %> -
-<% end %> diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb deleted file mode 100644 index 6ec95ca..0000000 --- a/app/views/messages/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

Editing message

- -<%= render 'form' %> - -<%= link_to 'Show', @message %> | -<%= link_to 'Back', messages_path %> diff --git a/app/views/messages/index.html.erb b/app/views/messages/index.html.erb deleted file mode 100644 index 3260cd6..0000000 --- a/app/views/messages/index.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -

Listing messages

- - - - - - - - - - - - - - - - <% @messages.each do |message| %> - - - - - - - - - - - - <% end %> - -
MessageSenderReceiverTitleContentTimestamp
<%= message.message_id %><%= message.sender_id %><%= message.receiver_id %><%= message.title %><%= message.content %><%= message.timestamp %><%= link_to 'Show', message %><%= link_to 'Edit', edit_message_path(message) %><%= link_to 'Destroy', message, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Message', new_message_path %> diff --git a/app/views/messages/index.json.jbuilder b/app/views/messages/index.json.jbuilder deleted file mode 100644 index 3a1a762..0000000 --- a/app/views/messages/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@messages) do |message| - json.extract! message, :id, :message_id, :sender_id, :receiver_id, :title, :content, :timestamp - json.url message_url(message, format: :json) -end diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erb deleted file mode 100644 index ac3bd30..0000000 --- a/app/views/messages/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New message

- -<%= render 'form' %> - -<%= link_to 'Back', messages_path %> diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb deleted file mode 100644 index 53d1e19..0000000 --- a/app/views/messages/show.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -

<%= notice %>

- -

- Message: - <%= @message.message_id %> -

- -

- Sender: - <%= @message.sender_id %> -

- -

- Receiver: - <%= @message.receiver_id %> -

- -

- Title: - <%= @message.title %> -

- -

- Content: - <%= @message.content %> -

- -

- Timestamp: - <%= @message.timestamp %> -

- -<%= link_to 'Edit', edit_message_path(@message) %> | -<%= link_to 'Back', messages_path %> diff --git a/app/views/messages/show.json.jbuilder b/app/views/messages/show.json.jbuilder deleted file mode 100644 index 54743c0..0000000 --- a/app/views/messages/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @message, :id, :message_id, :sender_id, :receiver_id, :title, :content, :timestamp, :created_at, :updated_at diff --git a/app/views/questions/_form.html.erb b/app/views/questions/_form.html.erb deleted file mode 100644 index 78637d1..0000000 --- a/app/views/questions/_form.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<%= form_for(@question) do |f| %> - <% if @question.errors.any? %> -
-

<%= pluralize(@question.errors.count, "error") %> prohibited this question from being saved:

- -
    - <% @question.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - - - title: <%= f.text_field :title %> - category: <%= f.select :category, options_for_select(%w[1 2 3 4 5]) %>
- content : <%= f.text_area(:content, size: '50x10') %>
- -<%=f.hidden_field :question_id, :value => 123 %> -<%=f.hidden_field :creator_id, :value => 100 %> -<%=f.hidden_field :answered, :value => false %> -<%=f.hidden_field :timestamp, :value => DateTime.now %> - - <%= f.submit %> - -<% end %> diff --git a/app/views/questions/edit.html.erb b/app/views/questions/edit.html.erb deleted file mode 100644 index 5a1b530..0000000 --- a/app/views/questions/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

Editing question

- -<%= render 'form' %> - -<%= link_to 'Show', @question %> | -<%= link_to 'Back', questions_path %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb deleted file mode 100644 index 7376c9c..0000000 --- a/app/views/questions/index.html.erb +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - -

Listing questions

- - - - - - - - - - - - - - - - - - <% @questions.each do |question| %> - - - - - - - - - - - - - - - <% end %> - -
QuestionCreatorTitleContentCategoryAnsweredClosing commentTimestamp
<%= question.id %><%= question.creator_id %><%= question.title %><%= question.content %><%= question.category %><%= question.answered %><%= question.closing_comment %><%= question.timestamp %><%= link_to 'Show', question %><%= link_to 'Edit', edit_question_path(question) %><%= link_to 'Destroy', question, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_answer_path(:question_id => question.id) %>
-
- - - - - -<%= link_to 'New Question', new_question_path %> - - - - \ No newline at end of file diff --git a/app/views/questions/index.json.jbuilder b/app/views/questions/index.json.jbuilder deleted file mode 100644 index e169dc3..0000000 --- a/app/views/questions/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@questions) do |question| - json.extract! question, :id, :question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp - json.url question_url(question, format: :json) -end diff --git a/app/views/questions/new.html.erb b/app/views/questions/new.html.erb deleted file mode 100644 index 8b78e7c..0000000 --- a/app/views/questions/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New question

- -<%= render 'form' %> - -<%= link_to 'Back', questions_path %> diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb deleted file mode 100644 index 83e8be3..0000000 --- a/app/views/questions/show.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -

<%= notice %>

- -

- Question: - <%= @question.question_id %> -

- -

- Creator: - <%= @question.creator_id %> -

- -

- Title: - <%= @question.title %> -

- -

- Content: - <%= @question.content %> -

- -

- Category: - <%= @question.category %> -

- -

- Answered: - <%= @question.answered %> -

- -

- Closing comment: - <%= @question.closing_comment %> -

- -

- Timestamp: - <%= @question.timestamp %> -

- -<%= link_to 'Edit', edit_question_path(@question) %> | -<%= link_to 'Back', questions_path %> diff --git a/app/views/questions/show.json.jbuilder b/app/views/questions/show.json.jbuilder deleted file mode 100644 index 4898bee..0000000 --- a/app/views/questions/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @question, :id, :question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp, :created_at, :updated_at diff --git a/app/views/responses/_form.html.erb b/app/views/responses/_form.html.erb deleted file mode 100644 index 00ef079..0000000 --- a/app/views/responses/_form.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<%= form_for(@response) do |f| %> - <% if @response.errors.any? %> -
-

<%= pluralize(@response.errors.count, "error") %> prohibited this response from being saved:

- -
    - <% @response.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - -
- <%= f.label :content %>
- <%= f.text_area :content, size: '50x10' %> -
-
- <%= f.submit %> -
- <%=f.hidden_field :response_id, :value => 456 %> - <%=f.hidden_field :creator_id, :value => 100 %> - <%=f.hidden_field :response_score, :value => 0 %> - <%=f.hidden_field :timestamp, :value => DateTime.now %> - <%=f.hidden_field :q_response_id, :value => params[:question_id] %> - <%=f.hidden_field :r_response_id, :value => params[:response_id] %> -<% end %> diff --git a/app/views/responses/edit.html.erb b/app/views/responses/edit.html.erb deleted file mode 100644 index 2e32b5b..0000000 --- a/app/views/responses/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

Editing response

- -<%= render 'form' %> - -<%= link_to 'Show', @response %> | -<%= link_to 'Back', responses_path %> diff --git a/app/views/responses/index.html.erb b/app/views/responses/index.html.erb deleted file mode 100644 index 0213966..0000000 --- a/app/views/responses/index.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -

Listing responses

- - - - - - - - - - - - - - - - - <% @responses.order('timestamp').reverse_order().take(3).each do |response| %> - - - - - - - - - - - - - <% end %> - -
ResponseQ responseR responseCreatorResponse scoreContentTimestamp
<%= response.id %><%= response.q_response_id %><%= response.r_response_id %><%= response.creator_id %><%= response.response_score %><%= response.content %><%= response.timestamp %><%= link_to 'Show', response %><%= link_to 'Edit', edit_response_path(response) %><%= link_to 'Destroy', response, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Response', new_response_path %> diff --git a/app/views/responses/index.json.jbuilder b/app/views/responses/index.json.jbuilder deleted file mode 100644 index 3329956..0000000 --- a/app/views/responses/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@responses) do |response| - json.extract! response, :id, :response_id, :q_response_id, :r_response_id, :creator_id, :response_score, :content, :timestamp - json.url response_url(response, format: :json) -end diff --git a/app/views/responses/new.html.erb b/app/views/responses/new.html.erb deleted file mode 100644 index 200360a..0000000 --- a/app/views/responses/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New response

- -<%= render 'form' %> - -<%= link_to 'Back', responses_path %> diff --git a/app/views/responses/show.html.erb b/app/views/responses/show.html.erb deleted file mode 100644 index 0646468..0000000 --- a/app/views/responses/show.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -

<%= notice %>

- -

- Response: - <%= @response.response_id %> -

- -

- Q response: - <%= @response.q_response_id %> -

- -

- R response: - <%= @response.r_response_id %> -

- -

- Creator: - <%= @response.creator_id %> -

- -

- Response score: - <%= @response.response_score %> -

- -

- Content: - <%= @response.content %> -

- -

- Timestamp: - <%= @response.timestamp %> -

- -<%= link_to 'Edit', edit_response_path(@response) %> | -<%= link_to 'Back', responses_path %> diff --git a/app/views/responses/show.json.jbuilder b/app/views/responses/show.json.jbuilder deleted file mode 100644 index 19a88b6..0000000 --- a/app/views/responses/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @response, :id, :response_id, :q_response_id, :r_response_id, :creator_id, :response_score, :content, :timestamp, :created_at, :updated_at diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb deleted file mode 100644 index 9c57c90..0000000 --- a/app/views/users/_form.html.erb +++ /dev/null @@ -1,45 +0,0 @@ -<%= form_for(@user) do |f| %> - <% if @user.errors.any? %> -
-

<%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:

- -
    - <% @user.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
- <% end %> - -
- <%= f.label :user_id %>
- <%= f.number_field :user_id %> -
-
- <%= f.label :username %>
- <%= f.text_field :username %> -
-
- <%= f.label :password %>
- <%= f.text_field :password %> -
-
- <%= f.label :first_name %>
- <%= f.text_field :first_name %> -
-
- <%= f.label :last_name %>
- <%= f.text_field :last_name %> -
-
- <%= f.label :score %>
- <%= f.number_field :score %> -
-
- <%= f.label :type %>
- <%= f.number_field :type %> -
-
- <%= f.submit %> -
-<% end %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb deleted file mode 100644 index 99bd4cc..0000000 --- a/app/views/users/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

Editing user

- -<%= render 'form' %> - -<%= link_to 'Show', @user %> | -<%= link_to 'Back', users_path %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb deleted file mode 100644 index 9337a7d..0000000 --- a/app/views/users/index.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -

Listing users

- - - - - - - - - - - - - - - - - <% @users.each do |user| %> - - - - - - - - - - - - - <% end %> - -
UserUsernamePasswordFirst nameLast nameScoreType
<%= user.user_id %><%= user.username %><%= user.password %><%= user.first_name %><%= user.last_name %><%= user.score %><%= user.type %><%= link_to 'Show', user %><%= link_to 'Edit', edit_user_path(user) %><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New User', new_user_path %> diff --git a/app/views/users/index.json.jbuilder b/app/views/users/index.json.jbuilder deleted file mode 100644 index f2da1b3..0000000 --- a/app/views/users/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@users) do |user| - json.extract! user, :id, :user_id, :username, :password, :first_name, :last_name, :score, :type - json.url user_url(user, format: :json) -end diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb deleted file mode 100644 index efc0404..0000000 --- a/app/views/users/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New user

- -<%= render 'form' %> - -<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb deleted file mode 100644 index 878f079..0000000 --- a/app/views/users/show.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -

<%= notice %>

- -

- User: - <%= @user.user_id %> -

- -

- Username: - <%= @user.username %> -

- -

- Password: - <%= @user.password %> -

- -

- First name: - <%= @user.first_name %> -

- -

- Last name: - <%= @user.last_name %> -

- -

- Score: - <%= @user.score %> -

- -

- Type: - <%= @user.type %> -

- -<%= link_to 'Edit', edit_user_path(@user) %> | -<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.json.jbuilder b/app/views/users/show.json.jbuilder deleted file mode 100644 index 23133ed..0000000 --- a/app/views/users/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @user, :id, :user_id, :username, :password, :first_name, :last_name, :score, :type, :created_at, :updated_at diff --git a/bin/bundle b/bin/bundle deleted file mode 100644 index e3c2f62..0000000 --- a/bin/bundle +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby.exe -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails deleted file mode 100644 index b9f8787..0000000 --- a/bin/rails +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby.exe -APP_PATH = File.expand_path('../../config/application', __FILE__) -require_relative '../config/boot' -require 'rails/commands' diff --git a/bin/rake b/bin/rake deleted file mode 100644 index f6ed5a2..0000000 --- a/bin/rake +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby.exe -require_relative '../config/boot' -require 'rake' -Rake.application.run From 7eabaf032d47262efd145353ad08ede57673b4df Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Mon, 10 Nov 2014 17:22:15 -0600 Subject: [PATCH 04/51] working? --- app/assets/images/.keep | 0 app/assets/javascripts/answers.js.coffee | 3 + app/assets/javascripts/application.js | 16 ++++ app/assets/javascripts/hackers.js.coffee | 3 + app/assets/javascripts/messages.js.coffee | 3 + app/assets/javascripts/questions.js.coffee | 3 + app/assets/javascripts/responses.js.coffee | 3 + app/assets/javascripts/users.js.coffee | 3 + app/assets/stylesheets/answers.css.scss | 3 + app/assets/stylesheets/application.css | 15 ++++ app/assets/stylesheets/hackers.css.scss | 3 + app/assets/stylesheets/messages.css.scss | 3 + app/assets/stylesheets/questions.css.scss | 3 + app/assets/stylesheets/responses.css.scss | 3 + app/assets/stylesheets/scaffolds.css.scss | 69 +++++++++++++++ app/assets/stylesheets/users.css.scss | 3 + app/controllers/answers_controller.rb | 78 +++++++++++++++++ app/controllers/application_controller.rb | 5 ++ app/controllers/concerns/.keep | 0 app/controllers/hackers_controller.rb | 74 ++++++++++++++++ app/controllers/messages_controller.rb | 74 ++++++++++++++++ app/controllers/questions_controller.rb | 79 +++++++++++++++++ app/controllers/responses_controller.rb | 77 +++++++++++++++++ app/controllers/users_controller.rb | 74 ++++++++++++++++ app/helpers/answers_helper.rb | 5 ++ app/helpers/application_helper.rb | 2 + app/helpers/hackers_helper.rb | 2 + app/helpers/messages_helper.rb | 2 + app/helpers/questions_helper.rb | 11 +++ app/helpers/responses_helper.rb | 2 + app/helpers/users_helper.rb | 2 + app/mailers/.keep | 0 app/models/.keep | 0 app/models/answer.rb | 2 + app/models/concerns/.keep | 0 app/models/hacker.rb | 2 + app/models/message.rb | 2 + app/models/question.rb | 3 + app/models/question2.rb | 2 + app/models/response.rb | 2 + app/models/user.rb | 2 + app/views/answers/_form.html.erb | 26 ++++++ app/views/answers/edit.html.erb | 6 ++ app/views/answers/index.html.erb | 37 ++++++++ app/views/answers/index.json.jbuilder | 4 + app/views/answers/new.html.erb | 5 ++ app/views/answers/show.html.erb | 34 ++++++++ app/views/answers/show.json.jbuilder | 1 + app/views/hackers/_form.html.erb | 41 +++++++++ app/views/hackers/edit.html.erb | 6 ++ app/views/hackers/index.html.erb | 37 ++++++++ app/views/hackers/index.json.jbuilder | 4 + app/views/hackers/new.html.erb | 5 ++ app/views/hackers/show.html.erb | 34 ++++++++ app/views/hackers/show.json.jbuilder | 1 + app/views/home/index.html.erb | 46 ++++++++++ app/views/layouts/application.html.erb | 14 ++++ app/views/messages/_form.html.erb | 41 +++++++++ app/views/messages/edit.html.erb | 6 ++ app/views/messages/index.html.erb | 35 ++++++++ app/views/messages/index.json.jbuilder | 4 + app/views/messages/new.html.erb | 5 ++ app/views/messages/show.html.erb | 34 ++++++++ app/views/messages/show.json.jbuilder | 1 + app/views/questions/_form.html.erb | 26 ++++++ app/views/questions/edit.html.erb | 6 ++ app/views/questions/index.html.erb | 98 ++++++++++++++++++++++ app/views/questions/index.json.jbuilder | 4 + app/views/questions/new.html.erb | 5 ++ app/views/questions/show.html.erb | 44 ++++++++++ app/views/questions/show.json.jbuilder | 1 + app/views/responses/_form.html.erb | 27 ++++++ app/views/responses/edit.html.erb | 6 ++ app/views/responses/index.html.erb | 37 ++++++++ app/views/responses/index.json.jbuilder | 4 + app/views/responses/new.html.erb | 5 ++ app/views/responses/show.html.erb | 39 +++++++++ app/views/responses/show.json.jbuilder | 1 + app/views/users/_form.html.erb | 45 ++++++++++ app/views/users/edit.html.erb | 6 ++ app/views/users/index.html.erb | 37 ++++++++ app/views/users/index.json.jbuilder | 4 + app/views/users/new.html.erb | 5 ++ app/views/users/show.html.erb | 39 +++++++++ app/views/users/show.json.jbuilder | 1 + bin/bundle | 3 + bin/rails | 4 + bin/rake | 4 + 88 files changed, 1516 insertions(+) create mode 100644 app/assets/images/.keep create mode 100644 app/assets/javascripts/answers.js.coffee create mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/hackers.js.coffee create mode 100644 app/assets/javascripts/messages.js.coffee create mode 100644 app/assets/javascripts/questions.js.coffee create mode 100644 app/assets/javascripts/responses.js.coffee create mode 100644 app/assets/javascripts/users.js.coffee create mode 100644 app/assets/stylesheets/answers.css.scss create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/hackers.css.scss create mode 100644 app/assets/stylesheets/messages.css.scss create mode 100644 app/assets/stylesheets/questions.css.scss create mode 100644 app/assets/stylesheets/responses.css.scss create mode 100644 app/assets/stylesheets/scaffolds.css.scss create mode 100644 app/assets/stylesheets/users.css.scss create mode 100644 app/controllers/answers_controller.rb create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/concerns/.keep create mode 100644 app/controllers/hackers_controller.rb create mode 100644 app/controllers/messages_controller.rb create mode 100644 app/controllers/questions_controller.rb create mode 100644 app/controllers/responses_controller.rb create mode 100644 app/controllers/users_controller.rb create mode 100644 app/helpers/answers_helper.rb create mode 100644 app/helpers/application_helper.rb create mode 100644 app/helpers/hackers_helper.rb create mode 100644 app/helpers/messages_helper.rb create mode 100644 app/helpers/questions_helper.rb create mode 100644 app/helpers/responses_helper.rb create mode 100644 app/helpers/users_helper.rb create mode 100644 app/mailers/.keep create mode 100644 app/models/.keep create mode 100644 app/models/answer.rb create mode 100644 app/models/concerns/.keep create mode 100644 app/models/hacker.rb create mode 100644 app/models/message.rb create mode 100644 app/models/question.rb create mode 100644 app/models/question2.rb create mode 100644 app/models/response.rb create mode 100644 app/models/user.rb create mode 100644 app/views/answers/_form.html.erb create mode 100644 app/views/answers/edit.html.erb create mode 100644 app/views/answers/index.html.erb create mode 100644 app/views/answers/index.json.jbuilder create mode 100644 app/views/answers/new.html.erb create mode 100644 app/views/answers/show.html.erb create mode 100644 app/views/answers/show.json.jbuilder create mode 100644 app/views/hackers/_form.html.erb create mode 100644 app/views/hackers/edit.html.erb create mode 100644 app/views/hackers/index.html.erb create mode 100644 app/views/hackers/index.json.jbuilder create mode 100644 app/views/hackers/new.html.erb create mode 100644 app/views/hackers/show.html.erb create mode 100644 app/views/hackers/show.json.jbuilder create mode 100644 app/views/home/index.html.erb create mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/messages/_form.html.erb create mode 100644 app/views/messages/edit.html.erb create mode 100644 app/views/messages/index.html.erb create mode 100644 app/views/messages/index.json.jbuilder create mode 100644 app/views/messages/new.html.erb create mode 100644 app/views/messages/show.html.erb create mode 100644 app/views/messages/show.json.jbuilder create mode 100644 app/views/questions/_form.html.erb create mode 100644 app/views/questions/edit.html.erb create mode 100644 app/views/questions/index.html.erb create mode 100644 app/views/questions/index.json.jbuilder create mode 100644 app/views/questions/new.html.erb create mode 100644 app/views/questions/show.html.erb create mode 100644 app/views/questions/show.json.jbuilder create mode 100644 app/views/responses/_form.html.erb create mode 100644 app/views/responses/edit.html.erb create mode 100644 app/views/responses/index.html.erb create mode 100644 app/views/responses/index.json.jbuilder create mode 100644 app/views/responses/new.html.erb create mode 100644 app/views/responses/show.html.erb create mode 100644 app/views/responses/show.json.jbuilder create mode 100644 app/views/users/_form.html.erb create mode 100644 app/views/users/edit.html.erb create mode 100644 app/views/users/index.html.erb create mode 100644 app/views/users/index.json.jbuilder create mode 100644 app/views/users/new.html.erb create mode 100644 app/views/users/show.html.erb create mode 100644 app/views/users/show.json.jbuilder create mode 100644 bin/bundle create mode 100644 bin/rails create mode 100644 bin/rake diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/answers.js.coffee b/app/assets/javascripts/answers.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/answers.js.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/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..d6925fa --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/app/assets/javascripts/hackers.js.coffee b/app/assets/javascripts/hackers.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/hackers.js.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/app/assets/javascripts/messages.js.coffee b/app/assets/javascripts/messages.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/messages.js.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/app/assets/javascripts/questions.js.coffee b/app/assets/javascripts/questions.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/questions.js.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/app/assets/javascripts/responses.js.coffee b/app/assets/javascripts/responses.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/responses.js.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/app/assets/javascripts/users.js.coffee b/app/assets/javascripts/users.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/users.js.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/app/assets/stylesheets/answers.css.scss b/app/assets/stylesheets/answers.css.scss new file mode 100644 index 0000000..24dc3ae --- /dev/null +++ b/app/assets/stylesheets/answers.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Answers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/app/assets/stylesheets/hackers.css.scss b/app/assets/stylesheets/hackers.css.scss new file mode 100644 index 0000000..3a13f75 --- /dev/null +++ b/app/assets/stylesheets/hackers.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Hackers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/messages.css.scss b/app/assets/stylesheets/messages.css.scss new file mode 100644 index 0000000..492f0fa --- /dev/null +++ b/app/assets/stylesheets/messages.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Messages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/questions.css.scss b/app/assets/stylesheets/questions.css.scss new file mode 100644 index 0000000..a7cd45c --- /dev/null +++ b/app/assets/stylesheets/questions.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Questions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/responses.css.scss b/app/assets/stylesheets/responses.css.scss new file mode 100644 index 0000000..ed1e1a4 --- /dev/null +++ b/app/assets/stylesheets/responses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Responses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 0000000..6ec6a8f --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss new file mode 100644 index 0000000..31a2eac --- /dev/null +++ b/app/assets/stylesheets/users.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Users controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb new file mode 100644 index 0000000..d2e7dc1 --- /dev/null +++ b/app/controllers/answers_controller.rb @@ -0,0 +1,78 @@ +class AnswersController < ApplicationController + before_action :set_answer, only: [:show, :edit, :update, :destroy] + + # GET /answers + # GET /answers.json + def index + @answers = Answer.all + end + + # GET /answers/1 + # GET /answers/1.json + def show + end + + # GET /answers/new + def new + @answer = Answer.new + end + + # GET /answers/1/edit + def edit + end + + # POST /answers + # POST /answers.json + def create + @answer = Answer.new(answer_params) + + respond_to do |format| + if @answer.save + format.html { redirect_to @answer, notice: 'Answer was successfully created.' } + format.json { render :show, status: :created, location: @answer } + else + format.html { render :new } + format.json { render json: @answer.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /answers/1 + # PATCH/PUT /answers/1.json + def update + respond_to do |format| + if @answer.update(answer_params) + format.html { redirect_to @answer, notice: 'Answer was successfully updated.' } + format.json { render :show, status: :ok, location: @answer } + else + format.html { render :edit } + format.json { render json: @answer.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /answers/1 + # DELETE /answers/1.json + def destroy + @answer.destroy + respond_to do |format| + format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_answer + @answer = Answer.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def answer_params + params.require(:answer).permit(:answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp) + end + + def answer + @answer.response_score=1 + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/hackers_controller.rb b/app/controllers/hackers_controller.rb new file mode 100644 index 0000000..a9dfef5 --- /dev/null +++ b/app/controllers/hackers_controller.rb @@ -0,0 +1,74 @@ +class HackersController < ApplicationController + before_action :set_hacker, only: [:show, :edit, :update, :destroy] + + # GET /hackers + # GET /hackers.json + def index + @hackers = Hacker.all + end + + # GET /hackers/1 + # GET /hackers/1.json + def show + end + + # GET /hackers/new + def new + @hacker = Hacker.new + end + + # GET /hackers/1/edit + def edit + end + + # POST /hackers + # POST /hackers.json + def create + @hacker = Hacker.new(hacker_params) + + respond_to do |format| + if @hacker.save + format.html { redirect_to @hacker, notice: 'Hacker was successfully created.' } + format.json { render :show, status: :created, location: @hacker } + else + format.html { render :new } + format.json { render json: @hacker.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /hackers/1 + # PATCH/PUT /hackers/1.json + def update + respond_to do |format| + if @hacker.update(hacker_params) + format.html { redirect_to @hacker, notice: 'Hacker was successfully updated.' } + format.json { render :show, status: :ok, location: @hacker } + else + format.html { render :edit } + format.json { render json: @hacker.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /hackers/1 + # DELETE /hackers/1.json + def destroy + @hacker.destroy + respond_to do |format| + format.html { redirect_to hackers_url, notice: 'Hacker was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_hacker + @hacker = Hacker.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def hacker_params + params.require(:hacker).permit(:username, :password, :first_name, :last_name, :score, :type) + end +end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb new file mode 100644 index 0000000..be72c33 --- /dev/null +++ b/app/controllers/messages_controller.rb @@ -0,0 +1,74 @@ +class MessagesController < ApplicationController + before_action :set_message, only: [:show, :edit, :update, :destroy] + + # GET /messages + # GET /messages.json + def index + @messages = Message.all + end + + # GET /messages/1 + # GET /messages/1.json + def show + end + + # GET /messages/new + def new + @message = Message.new + end + + # GET /messages/1/edit + def edit + end + + # POST /messages + # POST /messages.json + def create + @message = Message.new(message_params) + + respond_to do |format| + if @message.save + format.html { redirect_to @message, notice: 'Message was successfully created.' } + format.json { render :show, status: :created, location: @message } + else + format.html { render :new } + format.json { render json: @message.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /messages/1 + # PATCH/PUT /messages/1.json + def update + respond_to do |format| + if @message.update(message_params) + format.html { redirect_to @message, notice: 'Message was successfully updated.' } + format.json { render :show, status: :ok, location: @message } + else + format.html { render :edit } + format.json { render json: @message.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /messages/1 + # DELETE /messages/1.json + def destroy + @message.destroy + respond_to do |format| + format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_message + @message = Message.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def message_params + params.require(:message).permit(:message_id, :sender_id, :receiver_id, :title, :content, :timestamp) + end +end diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb new file mode 100644 index 0000000..d7e8f6b --- /dev/null +++ b/app/controllers/questions_controller.rb @@ -0,0 +1,79 @@ +class QuestionsController < ApplicationController + before_action :set_question, only: [:show, :edit, :update, :destroy] + + # GET /questions + # GET /questions.json + def index + @questions = Question.all + end + + # GET /questions/1 + # GET /questions/1.json + def show + end + + # GET /questions/new + def new + @question = Question.new + end + + # GET /questions/1/edit + def edit + end + + def answer + @question.answered="true" + end + + # POST /questions + # POST /questions.json + def create + @question = Question.new(question_params) + + respond_to do |format| + if @question.save + format.html { redirect_to @question, notice: 'Question was successfully created.' } + format.json { render :show, status: :created, location: @question } + else + format.html { render :new } + format.json { render json: @question.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /questions/1 + # PATCH/PUT /questions/1.json + def update + respond_to do |format| + if @question.update(question_params) + format.html { redirect_to @question, notice: 'Question was successfully updated.' } + format.json { render :show, status: :ok, location: @question } + else + format.html { render :edit } + format.json { render json: @question.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /questions/1 + # DELETE /questions/1.json + def destroy + @question.destroy + respond_to do |format| + format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_question + @question = Question.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def question_params + params.require(:question).permit(:question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp) + end + +end diff --git a/app/controllers/responses_controller.rb b/app/controllers/responses_controller.rb new file mode 100644 index 0000000..8be4fd3 --- /dev/null +++ b/app/controllers/responses_controller.rb @@ -0,0 +1,77 @@ +class ResponsesController < ApplicationController + before_action :set_response, only: [:show, :edit, :update, :destroy] + + # GET /responses + # GET /responses.json + def index + @responses = Response.all + end + + # GET /responses/1 + # GET /responses/1.json + def show + end + + # GET /responses/new + def new + @response = Response.new + if params[:question_id] + @response.q_response_id = params[:question_id] + end + end + + # GET /responses/1/edit + def edit + end + + # POST /responses + # POST /responses.json + def create + @response = Response.new(response_params) + + respond_to do |format| + if @response.save + format.html { redirect_to @response, notice: 'Response was successfully created.' } + format.json { render :show, status: :created, location: @response } + else + format.html { render :new } + format.json { render json: @response.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /responses/1 + # PATCH/PUT /responses/1.json + def update + respond_to do |format| + if @response.update(response_params) + format.html { redirect_to @response, notice: 'Response was successfully updated.' } + format.json { render :show, status: :ok, location: @response } + else + format.html { render :edit } + format.json { render json: @response.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /responses/1 + # DELETE /responses/1.json + def destroy + @response.destroy + respond_to do |format| + format.html { redirect_to responses_url, notice: 'Response was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_response + @response = Response.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def response_params + params.require(:response).permit(:response_id, :q_response_id, :r_response_id, :creator_id, :response_score, :content, :timestamp) + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 0000000..8441ffe --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,74 @@ +class UsersController < ApplicationController + before_action :set_user, only: [:show, :edit, :update, :destroy] + + # GET /users + # GET /users.json + def index + @users = User.all + end + + # GET /users/1 + # GET /users/1.json + def show + end + + # GET /users/new + def new + @user = User.new + end + + # GET /users/1/edit + def edit + end + + # POST /users + # POST /users.json + def create + @user = User.new(user_params) + + respond_to do |format| + if @user.save + format.html { redirect_to @user, notice: 'User was successfully created.' } + format.json { render :show, status: :created, location: @user } + else + format.html { render :new } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /users/1 + # PATCH/PUT /users/1.json + def update + respond_to do |format| + if @user.update(user_params) + format.html { redirect_to @user, notice: 'User was successfully updated.' } + format.json { render :show, status: :ok, location: @user } + else + format.html { render :edit } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /users/1 + # DELETE /users/1.json + def destroy + @user.destroy + respond_to do |format| + format.html { redirect_to users_url, notice: 'User was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_user + @user = User.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def user_params + params.require(:user).permit(:user_id, :username, :password, :first_name, :last_name, :score, :type) + end +end diff --git a/app/helpers/answers_helper.rb b/app/helpers/answers_helper.rb new file mode 100644 index 0000000..66727e9 --- /dev/null +++ b/app/helpers/answers_helper.rb @@ -0,0 +1,5 @@ +module AnswersHelper + def answer_question(answer) + return "" + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/helpers/hackers_helper.rb b/app/helpers/hackers_helper.rb new file mode 100644 index 0000000..885a3da --- /dev/null +++ b/app/helpers/hackers_helper.rb @@ -0,0 +1,2 @@ +module HackersHelper +end diff --git a/app/helpers/messages_helper.rb b/app/helpers/messages_helper.rb new file mode 100644 index 0000000..f1bca9f --- /dev/null +++ b/app/helpers/messages_helper.rb @@ -0,0 +1,2 @@ +module MessagesHelper +end diff --git a/app/helpers/questions_helper.rb b/app/helpers/questions_helper.rb new file mode 100644 index 0000000..4379775 --- /dev/null +++ b/app/helpers/questions_helper.rb @@ -0,0 +1,11 @@ +module QuestionsHelper + def answer_question(question) + if(question.answered==false) + question.answered=true + elsif + question.answered=false + end + question.save + return "" + end +end diff --git a/app/helpers/responses_helper.rb b/app/helpers/responses_helper.rb new file mode 100644 index 0000000..18dadea --- /dev/null +++ b/app/helpers/responses_helper.rb @@ -0,0 +1,2 @@ +module ResponsesHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 0000000..2310a24 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/answer.rb b/app/models/answer.rb new file mode 100644 index 0000000..ec007f9 --- /dev/null +++ b/app/models/answer.rb @@ -0,0 +1,2 @@ +class Answer < ActiveRecord::Base +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/hacker.rb b/app/models/hacker.rb new file mode 100644 index 0000000..c760509 --- /dev/null +++ b/app/models/hacker.rb @@ -0,0 +1,2 @@ +class Hacker < ActiveRecord::Base +end diff --git a/app/models/message.rb b/app/models/message.rb new file mode 100644 index 0000000..590e3e3 --- /dev/null +++ b/app/models/message.rb @@ -0,0 +1,2 @@ +class Message < ActiveRecord::Base +end diff --git a/app/models/question.rb b/app/models/question.rb new file mode 100644 index 0000000..cf6dc41 --- /dev/null +++ b/app/models/question.rb @@ -0,0 +1,3 @@ +class Question < ActiveRecord::Base + +end diff --git a/app/models/question2.rb b/app/models/question2.rb new file mode 100644 index 0000000..07a670b --- /dev/null +++ b/app/models/question2.rb @@ -0,0 +1,2 @@ +class Question2 < ActiveRecord::Base +end diff --git a/app/models/response.rb b/app/models/response.rb new file mode 100644 index 0000000..28aea65 --- /dev/null +++ b/app/models/response.rb @@ -0,0 +1,2 @@ +class Response < ActiveRecord::Base +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..4a57cf0 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,2 @@ +class User < ActiveRecord::Base +end diff --git a/app/views/answers/_form.html.erb b/app/views/answers/_form.html.erb new file mode 100644 index 0000000..78c7de2 --- /dev/null +++ b/app/views/answers/_form.html.erb @@ -0,0 +1,26 @@ +<%= form_for(@answer) do |f| %> + <% if @answer.errors.any? %> +
+

<%= pluralize(@answer.errors.count, "error") %> prohibited this answer from being saved:

+ +
    + <% @answer.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :content %>
+ <%= f.text_area :content, size: '50x10' %> +
+
+ <%= f.submit %> +
+ <%=f.hidden_field :response_id, :value => 456 %> + <%=f.hidden_field :creator_id, :value => 100 %> + <%=f.hidden_field :response_score, :value => 0 %> + <%=f.hidden_field :timestamp, :value => DateTime.now %> + <%=f.hidden_field :q_response_id, :value => params[:question_id] %> +<% end %> diff --git a/app/views/answers/edit.html.erb b/app/views/answers/edit.html.erb new file mode 100644 index 0000000..92f7d3f --- /dev/null +++ b/app/views/answers/edit.html.erb @@ -0,0 +1,6 @@ +

Editing answer

+ +<%= render 'form' %> + +<%= link_to 'Show', @answer %> | +<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb new file mode 100644 index 0000000..5d4a74e --- /dev/null +++ b/app/views/answers/index.html.erb @@ -0,0 +1,37 @@ +

Listing answers

+ + + + + + + + + + + + + + + + <% @answers.each do |answer| %> + + + + + + + + + + + + + + <% end %> + +
AnswerQ responseCreatorResponse scoreContentTimestamp
<%= answer.id %><%= answer.q_response_id %><%= answer.creator_id %><%= answer.response_score %><%= answer.content %><%= answer.timestamp %><%= link_to 'Show', answer %><%= link_to 'Edit', edit_answer_path(answer) %><%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= link_to 'Answer', answer_question(answer) %>
+ +
+ +<%= link_to 'New Answer', new_answer_path %> diff --git a/app/views/answers/index.json.jbuilder b/app/views/answers/index.json.jbuilder new file mode 100644 index 0000000..8403297 --- /dev/null +++ b/app/views/answers/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@answers) do |answer| + json.extract! answer, :id, :answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp + json.url answer_url(answer, format: :json) +end diff --git a/app/views/answers/new.html.erb b/app/views/answers/new.html.erb new file mode 100644 index 0000000..20757c4 --- /dev/null +++ b/app/views/answers/new.html.erb @@ -0,0 +1,5 @@ +

New answer

+ +<%= render 'form' %> + +<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/show.html.erb b/app/views/answers/show.html.erb new file mode 100644 index 0000000..57a0a90 --- /dev/null +++ b/app/views/answers/show.html.erb @@ -0,0 +1,34 @@ +

<%= notice %>

+ +

+ Answer: + <%= @answer.answer_id %> +

+ +

+ Q response: + <%= @answer.q_response_id %> +

+ +

+ Creator: + <%= @answer.creator_id %> +

+ +

+ Response score: + <%= @answer.response_score %> +

+ +

+ Content: + <%= @answer.content %> +

+ +

+ Timestamp: + <%= @answer.timestamp %> +

+ +<%= link_to 'Edit', edit_answer_path(@answer) %> | +<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/show.json.jbuilder b/app/views/answers/show.json.jbuilder new file mode 100644 index 0000000..0d70158 --- /dev/null +++ b/app/views/answers/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @answer, :id, :answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp, :created_at, :updated_at diff --git a/app/views/hackers/_form.html.erb b/app/views/hackers/_form.html.erb new file mode 100644 index 0000000..372d2ac --- /dev/null +++ b/app/views/hackers/_form.html.erb @@ -0,0 +1,41 @@ +<%= form_for(@hacker) do |f| %> + <% if @hacker.errors.any? %> +
+

<%= pluralize(@hacker.errors.count, "error") %> prohibited this hacker from being saved:

+ +
    + <% @hacker.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :username %>
+ <%= f.text_field :username %> +
+
+ <%= f.label :password %>
+ <%= f.text_field :password %> +
+
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name %> +
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name %> +
+
+ <%= f.label :score %>
+ <%= f.number_field :score %> +
+
+ <%= f.label :type %>
+ <%= f.number_field :type %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/hackers/edit.html.erb b/app/views/hackers/edit.html.erb new file mode 100644 index 0000000..b585a65 --- /dev/null +++ b/app/views/hackers/edit.html.erb @@ -0,0 +1,6 @@ +

Editing hacker

+ +<%= render 'form' %> + +<%= link_to 'Show', @hacker %> | +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/index.html.erb b/app/views/hackers/index.html.erb new file mode 100644 index 0000000..7f7918b --- /dev/null +++ b/app/views/hackers/index.html.erb @@ -0,0 +1,37 @@ +

Listing hackers

+ + + + + + + + + + + + + + + + + <% @hackers.each do |hacker| %> + + + + + + + + + + + + + <% end %> + +
idUsernamePasswordFirst nameLast nameScoreType
<%= hacker.id %><%= hacker.username %><%= hacker.password %><%= hacker.first_name %><%= hacker.last_name %><%= hacker.score %><%= hacker.type %><%= link_to 'Show', hacker %><%= link_to 'Edit', edit_hacker_path(hacker) %><%= link_to 'Destroy', hacker, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Hacker', new_hacker_path %> diff --git a/app/views/hackers/index.json.jbuilder b/app/views/hackers/index.json.jbuilder new file mode 100644 index 0000000..e13c550 --- /dev/null +++ b/app/views/hackers/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@hackers) do |hacker| + json.extract! hacker, :id, :username, :password, :first_name, :last_name, :score, :type + json.url hacker_url(hacker, format: :json) +end diff --git a/app/views/hackers/new.html.erb b/app/views/hackers/new.html.erb new file mode 100644 index 0000000..e141b1f --- /dev/null +++ b/app/views/hackers/new.html.erb @@ -0,0 +1,5 @@ +

New hacker

+ +<%= render 'form' %> + +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/show.html.erb b/app/views/hackers/show.html.erb new file mode 100644 index 0000000..32e9748 --- /dev/null +++ b/app/views/hackers/show.html.erb @@ -0,0 +1,34 @@ +

<%= notice %>

+ +

+ Username: + <%= @hacker.username %> +

+ +

+ Password: + <%= @hacker.password %> +

+ +

+ First name: + <%= @hacker.first_name %> +

+ +

+ Last name: + <%= @hacker.last_name %> +

+ +

+ Score: + <%= @hacker.score %> +

+ +

+ Type: + <%= @hacker.type %> +

+ +<%= link_to 'Edit', edit_hacker_path(@hacker) %> | +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/show.json.jbuilder b/app/views/hackers/show.json.jbuilder new file mode 100644 index 0000000..b71b64b --- /dev/null +++ b/app/views/hackers/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @hacker, :id, :username, :password, :first_name, :last_name, :score, :type, :created_at, :updated_at diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000..24e379e --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,46 @@ + + + + + + + + + question + + + + + + + + + + + +
+
+

question

+
+ + +
+ +
+ +
+

+ © Copyright by Seth +

+
+
+ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..33366d1 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Database + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb new file mode 100644 index 0000000..8c9baf0 --- /dev/null +++ b/app/views/messages/_form.html.erb @@ -0,0 +1,41 @@ +<%= form_for(@message) do |f| %> + <% if @message.errors.any? %> +
+

<%= pluralize(@message.errors.count, "error") %> prohibited this message from being saved:

+ +
    + <% @message.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :message_id %>
+ <%= f.number_field :message_id %> +
+
+ <%= f.label :sender_id %>
+ <%= f.number_field :sender_id %> +
+
+ <%= f.label :receiver_id %>
+ <%= f.number_field :receiver_id %> +
+
+ <%= f.label :title %>
+ <%= f.text_field :title %> +
+
+ <%= f.label :content %>
+ <%= f.text_area :content %> +
+
+ <%= f.label :timestamp %>
+ <%= f.datetime_select :timestamp %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb new file mode 100644 index 0000000..6ec95ca --- /dev/null +++ b/app/views/messages/edit.html.erb @@ -0,0 +1,6 @@ +

Editing message

+ +<%= render 'form' %> + +<%= link_to 'Show', @message %> | +<%= link_to 'Back', messages_path %> diff --git a/app/views/messages/index.html.erb b/app/views/messages/index.html.erb new file mode 100644 index 0000000..3260cd6 --- /dev/null +++ b/app/views/messages/index.html.erb @@ -0,0 +1,35 @@ +

Listing messages

+ + + + + + + + + + + + + + + + <% @messages.each do |message| %> + + + + + + + + + + + + <% end %> + +
MessageSenderReceiverTitleContentTimestamp
<%= message.message_id %><%= message.sender_id %><%= message.receiver_id %><%= message.title %><%= message.content %><%= message.timestamp %><%= link_to 'Show', message %><%= link_to 'Edit', edit_message_path(message) %><%= link_to 'Destroy', message, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Message', new_message_path %> diff --git a/app/views/messages/index.json.jbuilder b/app/views/messages/index.json.jbuilder new file mode 100644 index 0000000..3a1a762 --- /dev/null +++ b/app/views/messages/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@messages) do |message| + json.extract! message, :id, :message_id, :sender_id, :receiver_id, :title, :content, :timestamp + json.url message_url(message, format: :json) +end diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erb new file mode 100644 index 0000000..ac3bd30 --- /dev/null +++ b/app/views/messages/new.html.erb @@ -0,0 +1,5 @@ +

New message

+ +<%= render 'form' %> + +<%= link_to 'Back', messages_path %> diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb new file mode 100644 index 0000000..53d1e19 --- /dev/null +++ b/app/views/messages/show.html.erb @@ -0,0 +1,34 @@ +

<%= notice %>

+ +

+ Message: + <%= @message.message_id %> +

+ +

+ Sender: + <%= @message.sender_id %> +

+ +

+ Receiver: + <%= @message.receiver_id %> +

+ +

+ Title: + <%= @message.title %> +

+ +

+ Content: + <%= @message.content %> +

+ +

+ Timestamp: + <%= @message.timestamp %> +

+ +<%= link_to 'Edit', edit_message_path(@message) %> | +<%= link_to 'Back', messages_path %> diff --git a/app/views/messages/show.json.jbuilder b/app/views/messages/show.json.jbuilder new file mode 100644 index 0000000..54743c0 --- /dev/null +++ b/app/views/messages/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @message, :id, :message_id, :sender_id, :receiver_id, :title, :content, :timestamp, :created_at, :updated_at diff --git a/app/views/questions/_form.html.erb b/app/views/questions/_form.html.erb new file mode 100644 index 0000000..78637d1 --- /dev/null +++ b/app/views/questions/_form.html.erb @@ -0,0 +1,26 @@ +<%= form_for(@question) do |f| %> + <% if @question.errors.any? %> +
+

<%= pluralize(@question.errors.count, "error") %> prohibited this question from being saved:

+ +
    + <% @question.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + + + title: <%= f.text_field :title %> + category: <%= f.select :category, options_for_select(%w[1 2 3 4 5]) %>
+ content : <%= f.text_area(:content, size: '50x10') %>
+ +<%=f.hidden_field :question_id, :value => 123 %> +<%=f.hidden_field :creator_id, :value => 100 %> +<%=f.hidden_field :answered, :value => false %> +<%=f.hidden_field :timestamp, :value => DateTime.now %> + + <%= f.submit %> + +<% end %> diff --git a/app/views/questions/edit.html.erb b/app/views/questions/edit.html.erb new file mode 100644 index 0000000..5a1b530 --- /dev/null +++ b/app/views/questions/edit.html.erb @@ -0,0 +1,6 @@ +

Editing question

+ +<%= render 'form' %> + +<%= link_to 'Show', @question %> | +<%= link_to 'Back', questions_path %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb new file mode 100644 index 0000000..c3259c1 --- /dev/null +++ b/app/views/questions/index.html.erb @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + +

Listing questions

+ + + + + + + + + + + + + + + + + + <% @questions.each do |question| %> + + + + + + + + + + + + + + + + <% end %> + +
QuestionCreatorTitleContentCategoryAnsweredClosing commentTimestamp
<%= question.id %><%= question.creator_id %><%= question.title %><%= question.content %><%= question.category %><%= question.answered %><%= question.closing_comment %><%= question.timestamp %><%= link_to 'Show', question %><%= link_to 'Edit', edit_question_path(question) %><%= link_to 'Destroy', question, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%= link_to 'Answer', answer_question(question) %>
+
+ + + + + +<%= link_to 'New Question', new_question_path %> + + + + \ No newline at end of file diff --git a/app/views/questions/index.json.jbuilder b/app/views/questions/index.json.jbuilder new file mode 100644 index 0000000..e169dc3 --- /dev/null +++ b/app/views/questions/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@questions) do |question| + json.extract! question, :id, :question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp + json.url question_url(question, format: :json) +end diff --git a/app/views/questions/new.html.erb b/app/views/questions/new.html.erb new file mode 100644 index 0000000..8b78e7c --- /dev/null +++ b/app/views/questions/new.html.erb @@ -0,0 +1,5 @@ +

New question

+ +<%= render 'form' %> + +<%= link_to 'Back', questions_path %> diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb new file mode 100644 index 0000000..83e8be3 --- /dev/null +++ b/app/views/questions/show.html.erb @@ -0,0 +1,44 @@ +

<%= notice %>

+ +

+ Question: + <%= @question.question_id %> +

+ +

+ Creator: + <%= @question.creator_id %> +

+ +

+ Title: + <%= @question.title %> +

+ +

+ Content: + <%= @question.content %> +

+ +

+ Category: + <%= @question.category %> +

+ +

+ Answered: + <%= @question.answered %> +

+ +

+ Closing comment: + <%= @question.closing_comment %> +

+ +

+ Timestamp: + <%= @question.timestamp %> +

+ +<%= link_to 'Edit', edit_question_path(@question) %> | +<%= link_to 'Back', questions_path %> diff --git a/app/views/questions/show.json.jbuilder b/app/views/questions/show.json.jbuilder new file mode 100644 index 0000000..4898bee --- /dev/null +++ b/app/views/questions/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @question, :id, :question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp, :created_at, :updated_at diff --git a/app/views/responses/_form.html.erb b/app/views/responses/_form.html.erb new file mode 100644 index 0000000..00ef079 --- /dev/null +++ b/app/views/responses/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_for(@response) do |f| %> + <% if @response.errors.any? %> +
+

<%= pluralize(@response.errors.count, "error") %> prohibited this response from being saved:

+ +
    + <% @response.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :content %>
+ <%= f.text_area :content, size: '50x10' %> +
+
+ <%= f.submit %> +
+ <%=f.hidden_field :response_id, :value => 456 %> + <%=f.hidden_field :creator_id, :value => 100 %> + <%=f.hidden_field :response_score, :value => 0 %> + <%=f.hidden_field :timestamp, :value => DateTime.now %> + <%=f.hidden_field :q_response_id, :value => params[:question_id] %> + <%=f.hidden_field :r_response_id, :value => params[:response_id] %> +<% end %> diff --git a/app/views/responses/edit.html.erb b/app/views/responses/edit.html.erb new file mode 100644 index 0000000..2e32b5b --- /dev/null +++ b/app/views/responses/edit.html.erb @@ -0,0 +1,6 @@ +

Editing response

+ +<%= render 'form' %> + +<%= link_to 'Show', @response %> | +<%= link_to 'Back', responses_path %> diff --git a/app/views/responses/index.html.erb b/app/views/responses/index.html.erb new file mode 100644 index 0000000..0213966 --- /dev/null +++ b/app/views/responses/index.html.erb @@ -0,0 +1,37 @@ +

Listing responses

+ + + + + + + + + + + + + + + + + <% @responses.order('timestamp').reverse_order().take(3).each do |response| %> + + + + + + + + + + + + + <% end %> + +
ResponseQ responseR responseCreatorResponse scoreContentTimestamp
<%= response.id %><%= response.q_response_id %><%= response.r_response_id %><%= response.creator_id %><%= response.response_score %><%= response.content %><%= response.timestamp %><%= link_to 'Show', response %><%= link_to 'Edit', edit_response_path(response) %><%= link_to 'Destroy', response, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Response', new_response_path %> diff --git a/app/views/responses/index.json.jbuilder b/app/views/responses/index.json.jbuilder new file mode 100644 index 0000000..3329956 --- /dev/null +++ b/app/views/responses/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@responses) do |response| + json.extract! response, :id, :response_id, :q_response_id, :r_response_id, :creator_id, :response_score, :content, :timestamp + json.url response_url(response, format: :json) +end diff --git a/app/views/responses/new.html.erb b/app/views/responses/new.html.erb new file mode 100644 index 0000000..200360a --- /dev/null +++ b/app/views/responses/new.html.erb @@ -0,0 +1,5 @@ +

New response

+ +<%= render 'form' %> + +<%= link_to 'Back', responses_path %> diff --git a/app/views/responses/show.html.erb b/app/views/responses/show.html.erb new file mode 100644 index 0000000..0646468 --- /dev/null +++ b/app/views/responses/show.html.erb @@ -0,0 +1,39 @@ +

<%= notice %>

+ +

+ Response: + <%= @response.response_id %> +

+ +

+ Q response: + <%= @response.q_response_id %> +

+ +

+ R response: + <%= @response.r_response_id %> +

+ +

+ Creator: + <%= @response.creator_id %> +

+ +

+ Response score: + <%= @response.response_score %> +

+ +

+ Content: + <%= @response.content %> +

+ +

+ Timestamp: + <%= @response.timestamp %> +

+ +<%= link_to 'Edit', edit_response_path(@response) %> | +<%= link_to 'Back', responses_path %> diff --git a/app/views/responses/show.json.jbuilder b/app/views/responses/show.json.jbuilder new file mode 100644 index 0000000..19a88b6 --- /dev/null +++ b/app/views/responses/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @response, :id, :response_id, :q_response_id, :r_response_id, :creator_id, :response_score, :content, :timestamp, :created_at, :updated_at diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb new file mode 100644 index 0000000..9c57c90 --- /dev/null +++ b/app/views/users/_form.html.erb @@ -0,0 +1,45 @@ +<%= form_for(@user) do |f| %> + <% if @user.errors.any? %> +
+

<%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:

+ +
    + <% @user.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :user_id %>
+ <%= f.number_field :user_id %> +
+
+ <%= f.label :username %>
+ <%= f.text_field :username %> +
+
+ <%= f.label :password %>
+ <%= f.text_field :password %> +
+
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name %> +
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name %> +
+
+ <%= f.label :score %>
+ <%= f.number_field :score %> +
+
+ <%= f.label :type %>
+ <%= f.number_field :type %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb new file mode 100644 index 0000000..99bd4cc --- /dev/null +++ b/app/views/users/edit.html.erb @@ -0,0 +1,6 @@ +

Editing user

+ +<%= render 'form' %> + +<%= link_to 'Show', @user %> | +<%= link_to 'Back', users_path %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb new file mode 100644 index 0000000..9337a7d --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,37 @@ +

Listing users

+ + + + + + + + + + + + + + + + + <% @users.each do |user| %> + + + + + + + + + + + + + <% end %> + +
UserUsernamePasswordFirst nameLast nameScoreType
<%= user.user_id %><%= user.username %><%= user.password %><%= user.first_name %><%= user.last_name %><%= user.score %><%= user.type %><%= link_to 'Show', user %><%= link_to 'Edit', edit_user_path(user) %><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New User', new_user_path %> diff --git a/app/views/users/index.json.jbuilder b/app/views/users/index.json.jbuilder new file mode 100644 index 0000000..f2da1b3 --- /dev/null +++ b/app/views/users/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@users) do |user| + json.extract! user, :id, :user_id, :username, :password, :first_name, :last_name, :score, :type + json.url user_url(user, format: :json) +end diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 0000000..efc0404 --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,5 @@ +

New user

+ +<%= render 'form' %> + +<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 0000000..878f079 --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,39 @@ +

<%= notice %>

+ +

+ User: + <%= @user.user_id %> +

+ +

+ Username: + <%= @user.username %> +

+ +

+ Password: + <%= @user.password %> +

+ +

+ First name: + <%= @user.first_name %> +

+ +

+ Last name: + <%= @user.last_name %> +

+ +

+ Score: + <%= @user.score %> +

+ +

+ Type: + <%= @user.type %> +

+ +<%= link_to 'Edit', edit_user_path(@user) %> | +<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.json.jbuilder b/app/views/users/show.json.jbuilder new file mode 100644 index 0000000..23133ed --- /dev/null +++ b/app/views/users/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @user, :id, :user_id, :username, :password, :first_name, :last_name, :score, :type, :created_at, :updated_at diff --git a/bin/bundle b/bin/bundle new file mode 100644 index 0000000..e3c2f62 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby.exe +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100644 index 0000000..b9f8787 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby.exe +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100644 index 0000000..f6ed5a2 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby.exe +require_relative '../config/boot' +require 'rake' +Rake.application.run From 4c5fa407bdf7d19f57dfa512063f26777fa6320d Mon Sep 17 00:00:00 2001 From: Fabetron Date: Mon, 10 Nov 2014 17:29:45 -0600 Subject: [PATCH 05/51] validations1 --- app/models/answer.rb | 2 -- app/models/hacker.rb | 2 -- app/models/message.rb | 4 ++++ app/models/question.rb | 4 +++- app/models/response.rb | 9 +++++++++ app/models/user.rb | 3 +++ 6 files changed, 19 insertions(+), 5 deletions(-) delete mode 100644 app/models/answer.rb delete mode 100644 app/models/hacker.rb diff --git a/app/models/answer.rb b/app/models/answer.rb deleted file mode 100644 index ec007f9..0000000 --- a/app/models/answer.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Answer < ActiveRecord::Base -end diff --git a/app/models/hacker.rb b/app/models/hacker.rb deleted file mode 100644 index c760509..0000000 --- a/app/models/hacker.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Hacker < ActiveRecord::Base -end diff --git a/app/models/message.rb b/app/models/message.rb index 590e3e3..7dc09e6 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,2 +1,6 @@ class Message < ActiveRecord::Base + validates :Message_ID, presence: true, numericality: true + validates :Sender_ID, presence: true, numericality: true + validates :Reciever_ID, presence: true, numericality: true + validates :Timestamp, presence: true, end diff --git a/app/models/question.rb b/app/models/question.rb index cf6dc41..2785b79 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,3 +1,5 @@ class Question < ActiveRecord::Base - + validates :Question_ID, presence: true, numericality: true + validates :Creator_ID, presence: true, numericality: true + validates :Timestamp, presence: true end diff --git a/app/models/response.rb b/app/models/response.rb index 28aea65..0d1be34 100644 --- a/app/models/response.rb +++ b/app/models/response.rb @@ -1,2 +1,11 @@ class Response < ActiveRecord::Base + validates :Response_ID, presence: true, numericality: true + validates :Q_Response_ID, presence: true, numericality: true + validates :R_Response_ID, presence:true, numericality: true + validates :Creator_ID, presence: true, numericality: true + validates :Response_Score, presence: true, length: {minimum: 0000} + validates :Timestamp, presence: true + self.primary_key = :Response_ID + + end diff --git a/app/models/user.rb b/app/models/user.rb index 4a57cf0..f30c3e4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,2 +1,5 @@ class User < ActiveRecord::Base + validates :User_ID, numbericality: true + validates :Score, numbericality: true, length: {minumum: 0} + end From 3a5477759607e4d23880da70ad871e8ac2960816 Mon Sep 17 00:00:00 2001 From: fabetron Date: Mon, 10 Nov 2014 18:12:33 -0600 Subject: [PATCH 06/51] valid3 --- app/models/message.rb | 6 ++++++ app/models/question.rb | 6 ++++++ app/models/response.rb | 7 +++++++ app/models/user.rb | 9 +++++++++ 4 files changed, 28 insertions(+) diff --git a/app/models/message.rb b/app/models/message.rb index 7dc09e6..95d1f05 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,6 +1,12 @@ class Message < ActiveRecord::Base + validates :Message_ID, presence: true, numericality: true validates :Sender_ID, presence: true, numericality: true validates :Reciever_ID, presence: true, numericality: true validates :Timestamp, presence: true, + + self.primary_key = :Message_ID + + belongs_to :user + end diff --git a/app/models/question.rb b/app/models/question.rb index 2785b79..562a92d 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,5 +1,11 @@ class Question < ActiveRecord::Base + validates :Question_ID, presence: true, numericality: true validates :Creator_ID, presence: true, numericality: true validates :Timestamp, presence: true + + belongs_to :user + + self.primary_key = :Question_ID + end diff --git a/app/models/response.rb b/app/models/response.rb index 0d1be34..a1f27fd 100644 --- a/app/models/response.rb +++ b/app/models/response.rb @@ -1,11 +1,18 @@ class Response < ActiveRecord::Base + validates :Response_ID, presence: true, numericality: true validates :Q_Response_ID, presence: true, numericality: true validates :R_Response_ID, presence:true, numericality: true validates :Creator_ID, presence: true, numericality: true validates :Response_Score, presence: true, length: {minimum: 0000} validates :Timestamp, presence: true + self.primary_key = :Response_ID + belongs_to :user + + has_one :response + has_many :responses + end diff --git a/app/models/user.rb b/app/models/user.rb index f30c3e4..0a9c535 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,14 @@ class User < ActiveRecord::Base + validates :User_ID, numbericality: true validates :Score, numbericality: true, length: {minumum: 0} + self.primary_key = :User_ID + + has_many :responses + has_many :questions + has_many :messages + + + end From 7e199ce92618c8ad855f2cd7ee0083a167838ca6 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 16 Nov 2014 13:43:29 -0600 Subject: [PATCH 07/51] Revert "valid3" This reverts commit 3a5477759607e4d23880da70ad871e8ac2960816. --- app/models/message.rb | 6 ------ app/models/question.rb | 6 ------ app/models/response.rb | 7 ------- app/models/user.rb | 9 --------- 4 files changed, 28 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index 95d1f05..7dc09e6 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,12 +1,6 @@ class Message < ActiveRecord::Base - validates :Message_ID, presence: true, numericality: true validates :Sender_ID, presence: true, numericality: true validates :Reciever_ID, presence: true, numericality: true validates :Timestamp, presence: true, - - self.primary_key = :Message_ID - - belongs_to :user - end diff --git a/app/models/question.rb b/app/models/question.rb index 562a92d..2785b79 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,11 +1,5 @@ class Question < ActiveRecord::Base - validates :Question_ID, presence: true, numericality: true validates :Creator_ID, presence: true, numericality: true validates :Timestamp, presence: true - - belongs_to :user - - self.primary_key = :Question_ID - end diff --git a/app/models/response.rb b/app/models/response.rb index a1f27fd..0d1be34 100644 --- a/app/models/response.rb +++ b/app/models/response.rb @@ -1,18 +1,11 @@ class Response < ActiveRecord::Base - validates :Response_ID, presence: true, numericality: true validates :Q_Response_ID, presence: true, numericality: true validates :R_Response_ID, presence:true, numericality: true validates :Creator_ID, presence: true, numericality: true validates :Response_Score, presence: true, length: {minimum: 0000} validates :Timestamp, presence: true - self.primary_key = :Response_ID - belongs_to :user - - has_one :response - has_many :responses - end diff --git a/app/models/user.rb b/app/models/user.rb index 0a9c535..f30c3e4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,14 +1,5 @@ class User < ActiveRecord::Base - validates :User_ID, numbericality: true validates :Score, numbericality: true, length: {minumum: 0} - self.primary_key = :User_ID - - has_many :responses - has_many :questions - has_many :messages - - - end From ec969cf98c336265b0fe7a2979377cf5aa824580 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 16 Nov 2014 13:43:37 -0600 Subject: [PATCH 08/51] Revert "validations1" This reverts commit 4c5fa407bdf7d19f57dfa512063f26777fa6320d. --- app/models/answer.rb | 2 ++ app/models/hacker.rb | 2 ++ app/models/message.rb | 4 ---- app/models/question.rb | 4 +--- app/models/response.rb | 9 --------- app/models/user.rb | 3 --- 6 files changed, 5 insertions(+), 19 deletions(-) create mode 100644 app/models/answer.rb create mode 100644 app/models/hacker.rb diff --git a/app/models/answer.rb b/app/models/answer.rb new file mode 100644 index 0000000..ec007f9 --- /dev/null +++ b/app/models/answer.rb @@ -0,0 +1,2 @@ +class Answer < ActiveRecord::Base +end diff --git a/app/models/hacker.rb b/app/models/hacker.rb new file mode 100644 index 0000000..c760509 --- /dev/null +++ b/app/models/hacker.rb @@ -0,0 +1,2 @@ +class Hacker < ActiveRecord::Base +end diff --git a/app/models/message.rb b/app/models/message.rb index 7dc09e6..590e3e3 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,6 +1,2 @@ class Message < ActiveRecord::Base - validates :Message_ID, presence: true, numericality: true - validates :Sender_ID, presence: true, numericality: true - validates :Reciever_ID, presence: true, numericality: true - validates :Timestamp, presence: true, end diff --git a/app/models/question.rb b/app/models/question.rb index 2785b79..cf6dc41 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,5 +1,3 @@ class Question < ActiveRecord::Base - validates :Question_ID, presence: true, numericality: true - validates :Creator_ID, presence: true, numericality: true - validates :Timestamp, presence: true + end diff --git a/app/models/response.rb b/app/models/response.rb index 0d1be34..28aea65 100644 --- a/app/models/response.rb +++ b/app/models/response.rb @@ -1,11 +1,2 @@ class Response < ActiveRecord::Base - validates :Response_ID, presence: true, numericality: true - validates :Q_Response_ID, presence: true, numericality: true - validates :R_Response_ID, presence:true, numericality: true - validates :Creator_ID, presence: true, numericality: true - validates :Response_Score, presence: true, length: {minimum: 0000} - validates :Timestamp, presence: true - self.primary_key = :Response_ID - - end diff --git a/app/models/user.rb b/app/models/user.rb index f30c3e4..4a57cf0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,2 @@ class User < ActiveRecord::Base - validates :User_ID, numbericality: true - validates :Score, numbericality: true, length: {minumum: 0} - end From d2a115d581e88099faefb9b0b74e8295e5c67a43 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 16 Nov 2014 14:12:54 -0600 Subject: [PATCH 09/51] got rid of something that broke answer --- app/views/answers/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb index 5d4a74e..da21250 100644 --- a/app/views/answers/index.html.erb +++ b/app/views/answers/index.html.erb @@ -26,7 +26,7 @@ <%= link_to 'Edit', edit_answer_path(answer) %> <%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %> <%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %> - <%= link_to 'Answer', answer_question(answer) %> + <% end %> From 0b239ba45a93841a2d0433568cf8338f5f48b126 Mon Sep 17 00:00:00 2001 From: oscar Date: Mon, 17 Nov 2014 18:19:49 -0600 Subject: [PATCH 10/51] Added aboutPageStyle.css --- app/views/questions/aboutPageStyle.css | 404 +++++++++++++++++++++++++ 1 file changed, 404 insertions(+) create mode 100644 app/views/questions/aboutPageStyle.css diff --git a/app/views/questions/aboutPageStyle.css b/app/views/questions/aboutPageStyle.css new file mode 100644 index 0000000..e29a8ca --- /dev/null +++ b/app/views/questions/aboutPageStyle.css @@ -0,0 +1,404 @@ +@charset "utf-8"; + +/* Global Styles */ + +body { + margin-left: auto; + margin-right: auto; + width: 92%; + max-width: 960px; + padding-left: 2.275%; + padding-right: 2.275%; +} + +/* Header */ +header { + text-align: center; + display: block; +} +header .profileLogo .logoPlaceholder { + background-color: rgba(208,207,207,1.00); + width: 187px; + text-align: center; +} +header .logoPlaceholder span { + width: 80px; + height: 22px; + font-family: 'Montserrat', sans-serif; + color: rgba(255,255,255,1.00); + font-size: 30px; + font-weight: 700; + line-height: 53px; +} +header .profilePhoto { + background-color: rgba(237,237,237,1.00); + width: 259px; + border-radius: 50%; + height: 259px; + clear: both; +} +header .profileHeader h1 { + font-family: 'Montserrat', sans-serif; + color: rgba(146,146,146,1.00); + font-size: 30px; + font-weight: 700; + line-height: 24px; +} +header .profileHeader h3 { + font-family: sans-serif; + color: rgba(146,146,146,1.00); + font-size: 16px; + font-weight: 700; + line-height: 24px; +} +hr { + background-color: rgba(208,207,207,1.00); + height: 1px; +} +header .profileHeader p { + font-family: sans-serif; + color: rgba(146,146,146,1.00); + font-size: 14px; + font-weight: 400; + line-height: 1.8; + overflow-y: auto; +} +header .socialNetworkNavBar { + text-align: center; + display: block; + margin-top: 60px; + clear: both; +} +header .socialNetworkNavBar .socialNetworkNav { + border-radius: 50%; + cursor: pointer; +} +header .socialNetworkNavBar .socialNetworkNav img:hover { + opacity:0.5; +} +/* Main Content sections */ +.mainContent .section1 { + display: block; +} +.section1 .sectionTitle, .section2 .sectionTitle { + font-family: 'Montserrat', sans-serif; + color: rgba(146,146,146,1.00); + font-size: 18px; + font-weight: 700; + text-transform: uppercase; +} +.section1 .sectionTitleRule, .section2 .sectionTitleRule { + margin: 0 3% 0 0; + float: left; + clear: both; +} +.section1 .sectionTitleRule2, .section2 .sectionTitleRule2 { + background-color: rgba(208,207,207,1.00); + height: 1px; + padding: 0px; +} +.mainContent .section1 .section1Content { + font-family: ProximaNova; + font-size: 14px; + font-weight: 100; + color: rgba(208,207,207,1.00); +} +.mainContent .section1 .section1Content span { + color: rgba(146,146,146,1.00); + font-family: sans-serif; +} +.section2 .sectionContentTitle { + font-family: sans-serif; + color: rgba(146,146,146,1.00); + font-size: 18px; + font-weight: 700; +} + +.section2 .sectionContentSubTitle { + font-family: sans-serif; + color: rgba(68,67,67,1.00); + font-size: 14px; + font-weight: 400; +} +.section2 .sectionContent { + font-family: sans-serif; + color: rgba(146,146,146,1.00); + font-size: 14px; + font-weight: 400; + line-height: 1.8; +} +.mainContent { + display: block; +} +.mainContent .externalResourcesNav .externalResources { + background-color: rgba(208,207,207,1.00); + display: inline-block; + text-align: center; + margin-top: 0px; + padding-top: 3%; + cursor: pointer; +} +.mainContent .externalResourcesNav .externalResources:hover { + background-color: rgba(153,153,153,1.00); +} +.externalResourcesNav .externalResources a { + font-family: 'Montserrat', sans-serif; + color: rgba(255,255,255,1.00); + font-size: 14px; + font-weight: 400; + line-height: 18px; + text-decoration: none; +} +.stretch { + content: ''; + display: inline-block; + margin-left: 2%; + margin-right: 2%; +} +/* Footer */ +footer .footerDisclaimer { + font-family: sans-serif; + font-size: 14px; + line-height: 18px; + color: rgba(104,103,103,1.00); + font-weight: 700; +} +footer .footerDisclaimer span { + color: rgba(181,178,178,1.00); + font-weight: 400; +} +footer .footerNote { + font-family: sans-serif; + font-size: 14px; + line-height: 18px; + color: rgba(104,103,103,1.00); + font-weight: 700; +} +footer .footerNote span { + color: rgba(181,178,178,1.00); + font-weight: 400; +} + +/* Media query for Mobile devices*/ +@media only screen and (min-width : 285px) and (max-width : 480px) { +/* Header */ +header { + width: 100%; + float: none; +} +header .profileLogo .logoPlaceholder { + display: inline-block; +} +header .profilePhoto { + display: inline-block; +} +header .profileHeader { + text-align: center; + margin-top:10%; +} +header .profileHeader p { + text-align: justify; +} +header .socialNetworkNavBar { + text-align: center; + display: block; + margin-top: 60px; + clear: both; + margin-bottom: 15%; +} +header .socialNetworkNavBar .socialNetworkNav { + width: 60px; + height: 60px; + display: inline-block; + margin-right: 23px; +} +/* Main content sections */ +.mainContent .section1 { + text-align: center; + margin-bottom: 10%; +} +.section1 .section1Title, .section2 .section1Title { + text-align: center; +} +.section1 .sectionTitleRule, .section2 .sectionTitleRule { + width: 100%; +} +.section1 .sectionTitleRule2, .section2 .sectionTitleRule2 { + display: none; +} +.mainContent .section1 .section1Content { + display: inline-block; + text-align: left; + font-family: sans-serif; + text-align: justify; +} +.mainContent .section2 { + display: block; + text-align: center; +} +.section2 .section2Content { + margin-top: 10%; + text-align: justify; + margin-bottom: 10%; +} +.mainContent .externalResourcesNav { + margin-bottom: 10%; + +} +.mainContent .externalResourcesNav .externalResources { + width: 100%; + height: 35px; +} +/* Footer */ +footer { + display: block; + text-align: center; + font-family: sans-serif; +} +} + +/* Media Query for Tablets */ +@media only screen and (min-width : 481px) and (max-width : 1024px) { +/* Header */ +header { + width: 100%; + float: none; +} +header .profileLogo .logoPlaceholder { + display: inline-block; + font-family: 'Montserrat', sans-serif; +} +header .profilePhoto { + float: left; + clear: both; + margin-right: 3%; + margin-top:5%; +} +header .profileHeader { + text-align: left; + margin-top:7%; +} +header .socialNetworkNavBar .socialNetworkNav { + width: 74px; + height: 74px; + display: inline-block; + margin-right: 23px; +} +/* Main content and sections */ +.section1 .section1Title, .section2 .section1Title { + text-align: center; +} +.section1 .sectionTitleRule, .section2 .sectionTitleRule { + width: 100%; +} +.section1 .sectionTitleRule2, .section2 .sectionTitleRule2 { + display: none; +} +.mainContent .section1 .section1Content { + display: block; + margin: 0% 0% 0% 20%; + font-family: sans-serif;; + margin-top: 5%; + margin-bottom: 5%; +} +.mainContent .section2 { + clear: both; +} +.section2 .section2Content { + padding: 0px; + margin-left: 20%; + font-family: sans-serif; + margin-top: 5%; + margin-bottom: 5%; +} +.mainContent .externalResourcesNav { + margin-left: 20%; + margin-top: 40px; + margin-bottom: 40px; + text-align: center; + padding-top: 0px; + clear: both; +} +.mainContent .externalResourcesNav .externalResources { + width: 199px; + height: 48px; + margin-top: 5%; +} +/* Footer */ +footer .footerDisclaimer { + float: left; + margin-left: 3%; + font-family: sans-serif; +} +footer .footerNote { + float: right; + margin-right: 3%; + font-family: sans-serif; +} +} + +/* Desktops and laptops */ +@media only screen and (min-width:1025px) { +/* Header */ +header .profileLogo .logoPlaceholder { + float: left; + margin-bottom: 50px; +} +header .profilePhoto { + float: left; + clear: both; + margin-right: 3%; +} +header .profileHeader { + text-align: left; + padding-top: 10%; +} +header .socialNetworkNavBar .socialNetworkNav { + width: 74px; + height: 74px; + display: inline-block; + margin-right: 23px; +} +/* Main content sections */ +.section1 .sectionTitleRule, .section2 .sectionTitleRule { + width: 22.5%; +} +.mainContent .section1 .section1Content { + display: block; + margin-top: 0%; + margin-right: 0%; + margin-left: 26%; + margin-bottom: 0%; + font-family: sans-serif; +} +.mainContent .section2 { + clear: both; +} +.section2 .section2Content { + padding: 0px; + margin-left: 26%; + font-family: sans-serif; +} +.mainContent .externalResourcesNav { + margin-top: 40px; + margin-bottom: 40px; + text-align: center; + padding-top: 0px; + clear: both; +} +.mainContent .externalResourcesNav .externalResources { + width: 199px; + height: 48px; +} +/* Footer */ +footer .footerDisclaimer { + float: left; + margin-left: 3%; + font-family: sans-serif; +} +footer .footerNote { + float: right; + margin-right: 3%; + font-family: sans-serif; +} +} From 4c52fd9495217243493a24203f1f56a6986d04e9 Mon Sep 17 00:00:00 2001 From: fabetron Date: Mon, 17 Nov 2014 18:27:57 -0600 Subject: [PATCH 11/51] valid4 validations and --- app/models/answer.rb | 4 ++++ app/models/message.rb | 12 ++---------- app/models/question.rb | 13 ++++--------- app/models/response.rb | 18 ++---------------- app/models/user.rb | 17 +++++------------ 5 files changed, 17 insertions(+), 47 deletions(-) create mode 100644 app/models/answer.rb diff --git a/app/models/answer.rb b/app/models/answer.rb new file mode 100644 index 0000000..e50b2d3 --- /dev/null +++ b/app/models/answer.rb @@ -0,0 +1,4 @@ +class Answer < ActiveRecord::Base + self.primary_key = 'answer_id' + belongs_to :question +end \ No newline at end of file diff --git a/app/models/message.rb b/app/models/message.rb index 95d1f05..7cb9492 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,12 +1,4 @@ class Message < ActiveRecord::Base - - validates :Message_ID, presence: true, numericality: true - validates :Sender_ID, presence: true, numericality: true - validates :Reciever_ID, presence: true, numericality: true - validates :Timestamp, presence: true, - - self.primary_key = :Message_ID - - belongs_to :user - + self.primary_key = 'message_id' + belongs_to :user end diff --git a/app/models/question.rb b/app/models/question.rb index 562a92d..c1d737e 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,11 +1,6 @@ class Question < ActiveRecord::Base - - validates :Question_ID, presence: true, numericality: true - validates :Creator_ID, presence: true, numericality: true - validates :Timestamp, presence: true - - belongs_to :user - - self.primary_key = :Question_ID - + self.primary_key = 'question_id' + validates_uniqueness_of :content + belongs_to :user + has_many :answers end diff --git a/app/models/response.rb b/app/models/response.rb index a1f27fd..ad8dc83 100644 --- a/app/models/response.rb +++ b/app/models/response.rb @@ -1,18 +1,4 @@ class Response < ActiveRecord::Base - - validates :Response_ID, presence: true, numericality: true - validates :Q_Response_ID, presence: true, numericality: true - validates :R_Response_ID, presence:true, numericality: true - validates :Creator_ID, presence: true, numericality: true - validates :Response_Score, presence: true, length: {minimum: 0000} - validates :Timestamp, presence: true - - self.primary_key = :Response_ID - - belongs_to :user - - has_one :response - has_many :responses - - + self.primary_key = 'response_id' + belongs_to :user end diff --git a/app/models/user.rb b/app/models/user.rb index 0a9c535..45c61b7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,14 +1,7 @@ class User < ActiveRecord::Base - - validates :User_ID, numbericality: true - validates :Score, numbericality: true, length: {minumum: 0} - - self.primary_key = :User_ID - - has_many :responses - has_many :questions - has_many :messages - - - + self.primary_key = 'user_id' + has_many :responses + has_many :questions + has_many :answers + has_many :messages end From 414907577f530ebdc76d7210edb321cc9f0eeda4 Mon Sep 17 00:00:00 2001 From: fabetron Date: Mon, 17 Nov 2014 20:15:06 -0600 Subject: [PATCH 12/51] fixed broken validations --- app/models/answer.rb | 8 +------- app/models/message.rb | 5 ----- app/models/question.rb | 7 ------- app/models/response.rb | 5 ----- 4 files changed, 1 insertion(+), 24 deletions(-) diff --git a/app/models/answer.rb b/app/models/answer.rb index 2496489..0782015 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -1,8 +1,2 @@ -class Answer < ActiveRecord::Base -<<<<<<< HEAD - self.primary_key = 'answer_id' - belongs_to :question +class Answer < ActiveRecord::Bases end -======= -end ->>>>>>> d2a115d581e88099faefb9b0b74e8295e5c67a43 diff --git a/app/models/message.rb b/app/models/message.rb index 83403fe..590e3e3 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,7 +1,2 @@ class Message < ActiveRecord::Base -<<<<<<< HEAD - self.primary_key = 'message_id' - belongs_to :user -======= ->>>>>>> d2a115d581e88099faefb9b0b74e8295e5c67a43 end diff --git a/app/models/question.rb b/app/models/question.rb index 1c795c0..cabf312 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,10 +1,3 @@ class Question < ActiveRecord::Base -<<<<<<< HEAD - self.primary_key = 'question_id' validates_uniqueness_of :content - belongs_to :user - has_many :answers -======= - ->>>>>>> d2a115d581e88099faefb9b0b74e8295e5c67a43 end diff --git a/app/models/response.rb b/app/models/response.rb index 1ec51a9..28aea65 100644 --- a/app/models/response.rb +++ b/app/models/response.rb @@ -1,7 +1,2 @@ class Response < ActiveRecord::Base -<<<<<<< HEAD - self.primary_key = 'response_id' - belongs_to :user -======= ->>>>>>> d2a115d581e88099faefb9b0b74e8295e5c67a43 end From 516310479a1e8c12446afb1bc1511b90e9db6f88 Mon Sep 17 00:00:00 2001 From: fabetron Date: Tue, 18 Nov 2014 15:29:56 -0600 Subject: [PATCH 13/51] fixed answer model --- app/models/answer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/answer.rb b/app/models/answer.rb index 0782015..ec007f9 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -1,2 +1,2 @@ -class Answer < ActiveRecord::Bases +class Answer < ActiveRecord::Base end From a34a9a0af42f39154c6fc93672f89e20eb7e8cf6 Mon Sep 17 00:00:00 2001 From: fabetron Date: Tue, 18 Nov 2014 15:32:00 -0600 Subject: [PATCH 14/51] got rid of comment in questions view --- app/views/questions/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index c3259c1..f402fab 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -38,7 +38,7 @@ <% @questions.each do |question| %> @@ -83,6 +84,9 @@ <%= link_to 'Answer', answer_question(question) %> <% end %> + + +
From 802dabb26b74964527c11b9483d8c0ea62d3fd5d Mon Sep 17 00:00:00 2001 From: oscar Date: Tue, 25 Nov 2014 14:31:15 -0600 Subject: [PATCH 17/51] added to index.html.erb --- app/views/questions/index.html.erb | 55 +++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index c94c0c1..4cab76d 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -84,7 +84,6 @@ <%= link_to 'Answer', answer_question_path(question) %> <% end %> - @@ -97,6 +96,60 @@ <%= link_to 'New Question', new_question_path %> + + + + + + + + + +
Username  
+ + + + + +
Question +

Questions?Question?Question?

+ + + + + + + + + +
Username  
+ + + + + +
Question +

Questions?Question?Question?

+ + + + + + + + + +
Username  
+ + + + + + + +
Question +

Questions?Question?Question?

+ \ No newline at end of file From baf4d59ec5686c35fab902e925c4b3d5974cec2e Mon Sep 17 00:00:00 2001 From: Travis91 Date: Tue, 25 Nov 2014 15:24:25 -0600 Subject: [PATCH 18/51] updated asnsers to update question --- app/controllers/answers_controller.rb | 22 +++++++++++++++++++--- app/views/answers/index.html.erb | 3 ++- app/views/questions/index.html.erb | 2 +- config/routes.rb | 4 +++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index d2e7dc1..a9e42e3 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -1,6 +1,6 @@ class AnswersController < ApplicationController before_action :set_answer, only: [:show, :edit, :update, :destroy] - + # GET /answers # GET /answers.json def index @@ -20,7 +20,7 @@ def new # GET /answers/1/edit def edit end - + # POST /answers # POST /answers.json def create @@ -60,7 +60,21 @@ def destroy format.json { head :no_content } end end + # POST /answers + # POST /answers.json + def correct + @answer = Answer.find(params[:id]) + if @answer.response_score == 0 + @answer.response_score = 1 + + @question = Question.find(@answer.q_response_id) + @question.toggle!(:answered) + @answer.save + @question.save + end + redirect_to(:back) +end private # Use callbacks to share common setup or constraints between actions. def set_answer @@ -73,6 +87,8 @@ def answer_params end def answer - @answer.response_score=1 + @answer.response_score=0 end + + end diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb index da21250..d3f3c8e 100644 --- a/app/views/answers/index.html.erb +++ b/app/views/answers/index.html.erb @@ -9,7 +9,7 @@ Response score Content Timestamp - + @@ -26,6 +26,7 @@ <%= link_to 'Edit', edit_answer_path(answer) %> <%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %> <%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %> + <%= link_to 'Correct', correct_answer_path(answer)%> <% end %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 4cab76d..94e5c4c 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -81,7 +81,7 @@ <%= link_to 'Edit', edit_question_path(question) %> <%= link_to 'Destroy', question, method: :delete, data: { confirm: 'Are you sure?' } %> <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> - <%= link_to 'Answer', answer_question_path(question) %> + <%= link_to 'Answer', answer_question_path(question)%> <% end %> diff --git a/config/routes.rb b/config/routes.rb index a7e2127..c3eaf3e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,9 @@ Rails.application.routes.draw do resources :hackers - resources :answers + resources :answers do + get 'correct', :on => :member + end root 'questions#index' From 55d50cec7beb2cedf516dfd24b91b80a80e2ad8b Mon Sep 17 00:00:00 2001 From: Travis91 Date: Wed, 26 Nov 2014 12:59:17 -0600 Subject: [PATCH 19/51] answers updates question answered statud --- app/controllers/answers_controller.rb | 2 +- app/controllers/questions_controller.rb | 3 ++- config/routes.rb | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index a9e42e3..2aacd80 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -1,6 +1,6 @@ class AnswersController < ApplicationController before_action :set_answer, only: [:show, :edit, :update, :destroy] - + belongs_to :question # GET /answers # GET /answers.json def index diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 11b5e10..ea943ee 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -1,6 +1,7 @@ class QuestionsController < ApplicationController +has_many :answers before_action :set_question, only: [:show, :edit, :update, :destroy] - + # GET /questions # GET /questions.json def index diff --git a/config/routes.rb b/config/routes.rb index c3eaf3e..dffe6b3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,8 @@ Rails.application.routes.draw do resources :hackers - resources :answers do - get 'correct', :on => :member - end + # resources :answers do + root 'questions#index' @@ -11,7 +10,11 @@ resources :questions do get 'answer', :on => :member + resources :answers do + get 'correct', :on => :member end +end + resources :messages resources :users From 0afa6c7a09d3b9d04218ba293a2a729dacc51949 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Wed, 26 Nov 2014 13:00:02 -0600 Subject: [PATCH 20/51] minor questions bug fix --- app/controllers/answers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index 2aacd80..e759c79 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -1,6 +1,6 @@ class AnswersController < ApplicationController before_action :set_answer, only: [:show, :edit, :update, :destroy] - belongs_to :question + # GET /answers # GET /answers.json def index From 045b9632666a6ade95cd8dc4994747e508af7457 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Wed, 26 Nov 2014 13:19:56 -0600 Subject: [PATCH 21/51] correct stuff --- app/models/answer.rb | 1 + app/models/question.rb | 1 + config/routes.rb | 14 +++++++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/models/answer.rb b/app/models/answer.rb index ec007f9..e534e3c 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -1,2 +1,3 @@ class Answer < ActiveRecord::Base +belongs_to :question end diff --git a/app/models/question.rb b/app/models/question.rb index cabf312..a283e69 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,3 +1,4 @@ class Question < ActiveRecord::Base +has_many :answers validates_uniqueness_of :content end diff --git a/config/routes.rb b/config/routes.rb index dffe6b3..9b4b243 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,9 @@ Rails.application.routes.draw do resources :hackers - # resources :answers do - + resources :answers do + get 'correct', :on => :member + end root 'questions#index' @@ -10,15 +11,14 @@ resources :questions do get 'answer', :on => :member - resources :answers do - get 'correct', :on => :member end -end - + do + resources :answers + end resources :messages resources :users - + resources :hackers # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". From 9beae54baa84ba449d90500de0ecb32085ee7078 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Wed, 26 Nov 2014 13:31:27 -0600 Subject: [PATCH 22/51] working stuff --- app/controllers/questions_controller.rb | 1 - config/routes.rb | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index ea943ee..3733604 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -1,5 +1,4 @@ class QuestionsController < ApplicationController -has_many :answers before_action :set_question, only: [:show, :edit, :update, :destroy] # GET /questions diff --git a/config/routes.rb b/config/routes.rb index 9b4b243..5bfdf83 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,10 +11,9 @@ resources :questions do get 'answer', :on => :member + resources :answers end - do - resources :answers - end + resources :messages resources :users From 189b51b40ac07db8f5f02063d751126194564a74 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Wed, 26 Nov 2014 17:05:52 -0600 Subject: [PATCH 23/51] shows answers for specific question --- app/controllers/questions_controller.rb | 2 ++ app/views/questions/show.html.erb | 32 +++++++++++++++++++ db/migrate/20141013185823_create_questions.rb | 2 ++ 3 files changed, 36 insertions(+) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 3733604..579c299 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -5,11 +5,13 @@ class QuestionsController < ApplicationController # GET /questions.json def index @questions = Question.all + end # GET /questions/1 # GET /questions/1.json def show + @answers = Answer.where( q_response_id: @question.id) end # GET /questions/new diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 83e8be3..c3ec54d 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -42,3 +42,35 @@ <%= link_to 'Edit', edit_question_path(@question) %> | <%= link_to 'Back', questions_path %> + + + + + + + + + + + + +
AnswerQ responseCreatorResponse scoreContentTimestamp
+ + <% @answers.each do |answer| %> + + + + + + + + + + + + + + + <% end %> + +
<%= answer.id %><%= answer.q_response_id %><%= answer.creator_id %><%= answer.response_score %><%= answer.content %><%= answer.timestamp %><%= link_to 'Show', answer %><%= link_to 'Edit', edit_answer_path(answer) %><%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= link_to 'Correct', correct_answer_path(answer)%>
diff --git a/db/migrate/20141013185823_create_questions.rb b/db/migrate/20141013185823_create_questions.rb index ab88d5e..d64c112 100644 --- a/db/migrate/20141013185823_create_questions.rb +++ b/db/migrate/20141013185823_create_questions.rb @@ -1,6 +1,8 @@ class CreateQuestions < ActiveRecord::Migration def change + create_table :questions do |t| + t.belong_to :question t.integer :question_id t.integer :creator_id t.string :title From e8fe2955c0521ffe49d6d39184cb5a014249d4e4 Mon Sep 17 00:00:00 2001 From: fabetron Date: Wed, 26 Nov 2014 18:15:19 -0600 Subject: [PATCH 24/51] makes content and title unique and filled in --- app/models/question.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/question.rb b/app/models/question.rb index a283e69..50ffaec 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,4 +1,7 @@ class Question < ActiveRecord::Base has_many :answers validates_uniqueness_of :content + validates_uniqueness_of :title + validates_presence_of :content + validates_presence_of :title end From 1aab6638651382e2afd175582e47447efba7aed5 Mon Sep 17 00:00:00 2001 From: fabetron Date: Wed, 26 Nov 2014 18:21:44 -0600 Subject: [PATCH 25/51] fixed users model --- app/models/user.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 10bf18d..4a57cf0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,10 +1,2 @@ class User < ActiveRecord::Base -<<<<<<< HEAD - self.primary_key = 'user_id' - has_many :responses - has_many :questions - has_many :answers - has_many :messages -======= ->>>>>>> d2a115d581e88099faefb9b0b74e8295e5c67a43 end From 23a0cd0cc0d189bf740b0e8a3a5261351c08caaf Mon Sep 17 00:00:00 2001 From: fabetron Date: Wed, 26 Nov 2014 18:49:17 -0600 Subject: [PATCH 26/51] changed schema --- db/schema.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.rb b/db/schema.rb index 261e370..adc9070 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,6 +14,7 @@ ActiveRecord::Schema.define(version: 20141020233116) do create_table "answers", force: true do |t| + t.integer "question_id" t.integer "answer_id" t.integer "q_response_id" t.integer "creator_id" From 75e3861bf485c3dcb3900a1e0d9b994339693d7f Mon Sep 17 00:00:00 2001 From: oscar Date: Wed, 26 Nov 2014 20:00:22 -0600 Subject: [PATCH 27/51] Deleted aboutPageStyle.css and added log in to index.html.erb --- app/views/questions/aboutPageStyle.css | 404 ------------------------- 1 file changed, 404 deletions(-) delete mode 100644 app/views/questions/aboutPageStyle.css diff --git a/app/views/questions/aboutPageStyle.css b/app/views/questions/aboutPageStyle.css deleted file mode 100644 index e29a8ca..0000000 --- a/app/views/questions/aboutPageStyle.css +++ /dev/null @@ -1,404 +0,0 @@ -@charset "utf-8"; - -/* Global Styles */ - -body { - margin-left: auto; - margin-right: auto; - width: 92%; - max-width: 960px; - padding-left: 2.275%; - padding-right: 2.275%; -} - -/* Header */ -header { - text-align: center; - display: block; -} -header .profileLogo .logoPlaceholder { - background-color: rgba(208,207,207,1.00); - width: 187px; - text-align: center; -} -header .logoPlaceholder span { - width: 80px; - height: 22px; - font-family: 'Montserrat', sans-serif; - color: rgba(255,255,255,1.00); - font-size: 30px; - font-weight: 700; - line-height: 53px; -} -header .profilePhoto { - background-color: rgba(237,237,237,1.00); - width: 259px; - border-radius: 50%; - height: 259px; - clear: both; -} -header .profileHeader h1 { - font-family: 'Montserrat', sans-serif; - color: rgba(146,146,146,1.00); - font-size: 30px; - font-weight: 700; - line-height: 24px; -} -header .profileHeader h3 { - font-family: sans-serif; - color: rgba(146,146,146,1.00); - font-size: 16px; - font-weight: 700; - line-height: 24px; -} -hr { - background-color: rgba(208,207,207,1.00); - height: 1px; -} -header .profileHeader p { - font-family: sans-serif; - color: rgba(146,146,146,1.00); - font-size: 14px; - font-weight: 400; - line-height: 1.8; - overflow-y: auto; -} -header .socialNetworkNavBar { - text-align: center; - display: block; - margin-top: 60px; - clear: both; -} -header .socialNetworkNavBar .socialNetworkNav { - border-radius: 50%; - cursor: pointer; -} -header .socialNetworkNavBar .socialNetworkNav img:hover { - opacity:0.5; -} -/* Main Content sections */ -.mainContent .section1 { - display: block; -} -.section1 .sectionTitle, .section2 .sectionTitle { - font-family: 'Montserrat', sans-serif; - color: rgba(146,146,146,1.00); - font-size: 18px; - font-weight: 700; - text-transform: uppercase; -} -.section1 .sectionTitleRule, .section2 .sectionTitleRule { - margin: 0 3% 0 0; - float: left; - clear: both; -} -.section1 .sectionTitleRule2, .section2 .sectionTitleRule2 { - background-color: rgba(208,207,207,1.00); - height: 1px; - padding: 0px; -} -.mainContent .section1 .section1Content { - font-family: ProximaNova; - font-size: 14px; - font-weight: 100; - color: rgba(208,207,207,1.00); -} -.mainContent .section1 .section1Content span { - color: rgba(146,146,146,1.00); - font-family: sans-serif; -} -.section2 .sectionContentTitle { - font-family: sans-serif; - color: rgba(146,146,146,1.00); - font-size: 18px; - font-weight: 700; -} - -.section2 .sectionContentSubTitle { - font-family: sans-serif; - color: rgba(68,67,67,1.00); - font-size: 14px; - font-weight: 400; -} -.section2 .sectionContent { - font-family: sans-serif; - color: rgba(146,146,146,1.00); - font-size: 14px; - font-weight: 400; - line-height: 1.8; -} -.mainContent { - display: block; -} -.mainContent .externalResourcesNav .externalResources { - background-color: rgba(208,207,207,1.00); - display: inline-block; - text-align: center; - margin-top: 0px; - padding-top: 3%; - cursor: pointer; -} -.mainContent .externalResourcesNav .externalResources:hover { - background-color: rgba(153,153,153,1.00); -} -.externalResourcesNav .externalResources a { - font-family: 'Montserrat', sans-serif; - color: rgba(255,255,255,1.00); - font-size: 14px; - font-weight: 400; - line-height: 18px; - text-decoration: none; -} -.stretch { - content: ''; - display: inline-block; - margin-left: 2%; - margin-right: 2%; -} -/* Footer */ -footer .footerDisclaimer { - font-family: sans-serif; - font-size: 14px; - line-height: 18px; - color: rgba(104,103,103,1.00); - font-weight: 700; -} -footer .footerDisclaimer span { - color: rgba(181,178,178,1.00); - font-weight: 400; -} -footer .footerNote { - font-family: sans-serif; - font-size: 14px; - line-height: 18px; - color: rgba(104,103,103,1.00); - font-weight: 700; -} -footer .footerNote span { - color: rgba(181,178,178,1.00); - font-weight: 400; -} - -/* Media query for Mobile devices*/ -@media only screen and (min-width : 285px) and (max-width : 480px) { -/* Header */ -header { - width: 100%; - float: none; -} -header .profileLogo .logoPlaceholder { - display: inline-block; -} -header .profilePhoto { - display: inline-block; -} -header .profileHeader { - text-align: center; - margin-top:10%; -} -header .profileHeader p { - text-align: justify; -} -header .socialNetworkNavBar { - text-align: center; - display: block; - margin-top: 60px; - clear: both; - margin-bottom: 15%; -} -header .socialNetworkNavBar .socialNetworkNav { - width: 60px; - height: 60px; - display: inline-block; - margin-right: 23px; -} -/* Main content sections */ -.mainContent .section1 { - text-align: center; - margin-bottom: 10%; -} -.section1 .section1Title, .section2 .section1Title { - text-align: center; -} -.section1 .sectionTitleRule, .section2 .sectionTitleRule { - width: 100%; -} -.section1 .sectionTitleRule2, .section2 .sectionTitleRule2 { - display: none; -} -.mainContent .section1 .section1Content { - display: inline-block; - text-align: left; - font-family: sans-serif; - text-align: justify; -} -.mainContent .section2 { - display: block; - text-align: center; -} -.section2 .section2Content { - margin-top: 10%; - text-align: justify; - margin-bottom: 10%; -} -.mainContent .externalResourcesNav { - margin-bottom: 10%; - -} -.mainContent .externalResourcesNav .externalResources { - width: 100%; - height: 35px; -} -/* Footer */ -footer { - display: block; - text-align: center; - font-family: sans-serif; -} -} - -/* Media Query for Tablets */ -@media only screen and (min-width : 481px) and (max-width : 1024px) { -/* Header */ -header { - width: 100%; - float: none; -} -header .profileLogo .logoPlaceholder { - display: inline-block; - font-family: 'Montserrat', sans-serif; -} -header .profilePhoto { - float: left; - clear: both; - margin-right: 3%; - margin-top:5%; -} -header .profileHeader { - text-align: left; - margin-top:7%; -} -header .socialNetworkNavBar .socialNetworkNav { - width: 74px; - height: 74px; - display: inline-block; - margin-right: 23px; -} -/* Main content and sections */ -.section1 .section1Title, .section2 .section1Title { - text-align: center; -} -.section1 .sectionTitleRule, .section2 .sectionTitleRule { - width: 100%; -} -.section1 .sectionTitleRule2, .section2 .sectionTitleRule2 { - display: none; -} -.mainContent .section1 .section1Content { - display: block; - margin: 0% 0% 0% 20%; - font-family: sans-serif;; - margin-top: 5%; - margin-bottom: 5%; -} -.mainContent .section2 { - clear: both; -} -.section2 .section2Content { - padding: 0px; - margin-left: 20%; - font-family: sans-serif; - margin-top: 5%; - margin-bottom: 5%; -} -.mainContent .externalResourcesNav { - margin-left: 20%; - margin-top: 40px; - margin-bottom: 40px; - text-align: center; - padding-top: 0px; - clear: both; -} -.mainContent .externalResourcesNav .externalResources { - width: 199px; - height: 48px; - margin-top: 5%; -} -/* Footer */ -footer .footerDisclaimer { - float: left; - margin-left: 3%; - font-family: sans-serif; -} -footer .footerNote { - float: right; - margin-right: 3%; - font-family: sans-serif; -} -} - -/* Desktops and laptops */ -@media only screen and (min-width:1025px) { -/* Header */ -header .profileLogo .logoPlaceholder { - float: left; - margin-bottom: 50px; -} -header .profilePhoto { - float: left; - clear: both; - margin-right: 3%; -} -header .profileHeader { - text-align: left; - padding-top: 10%; -} -header .socialNetworkNavBar .socialNetworkNav { - width: 74px; - height: 74px; - display: inline-block; - margin-right: 23px; -} -/* Main content sections */ -.section1 .sectionTitleRule, .section2 .sectionTitleRule { - width: 22.5%; -} -.mainContent .section1 .section1Content { - display: block; - margin-top: 0%; - margin-right: 0%; - margin-left: 26%; - margin-bottom: 0%; - font-family: sans-serif; -} -.mainContent .section2 { - clear: both; -} -.section2 .section2Content { - padding: 0px; - margin-left: 26%; - font-family: sans-serif; -} -.mainContent .externalResourcesNav { - margin-top: 40px; - margin-bottom: 40px; - text-align: center; - padding-top: 0px; - clear: both; -} -.mainContent .externalResourcesNav .externalResources { - width: 199px; - height: 48px; -} -/* Footer */ -footer .footerDisclaimer { - float: left; - margin-left: 3%; - font-family: sans-serif; -} -footer .footerNote { - float: right; - margin-right: 3%; - font-family: sans-serif; -} -} From bd1ef15915a86a3d4b8a7433cdede25559c5c3dc Mon Sep 17 00:00:00 2001 From: oscar Date: Wed, 26 Nov 2014 20:00:58 -0600 Subject: [PATCH 28/51] Added log in header --- app/views/questions/index.html.erb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 94e5c4c..0a3b8da 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -6,6 +6,15 @@ +
+
+Username: 
+Password: 
+
+ +
- +<% @questions.each do |question| %> - - + +
Username   <%= question.creator_id %>  
+

<%=question.content%>

Question -

Questions?Question?Question?

- +<% end %> From 131429cc6a8f26e981df95113cbde84c435b07e4 Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Sun, 30 Nov 2014 06:58:17 -0600 Subject: [PATCH 31/51] login/logout added, at top of questions for now --- Gemfile | 2 +- Gemfile.lock | 2 ++ app/controllers/application_controller.rb | 6 ++++++ app/models/hacker.rb | 3 ++- app/models/user.rb | 5 +++++ app/views/hackers/_form.html.erb | 4 ++++ app/views/questions/index.html.erb | 8 ++++++-- app/views/users/_form.html.erb | 6 +----- app/views/users/index.html.erb | 2 +- config/routes.rb | 7 +++++++ db/schema.rb | 8 +++++++- 11 files changed, 42 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index 5f791cc..2658b93 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc # Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' +gem 'bcrypt', '~> 3.1.7' # Use unicorn as the app server # gem 'unicorn' diff --git a/Gemfile.lock b/Gemfile.lock index b6c0f91..cbac2c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM thread_safe (~> 0.1) tzinfo (~> 1.1) arel (5.0.1.20140414130214) + bcrypt (3.1.9-x86-mingw32) builder (3.2.2) coffee-rails (4.0.1) coffee-script (>= 2.2.0) @@ -109,6 +110,7 @@ PLATFORMS x86-mingw32 DEPENDENCIES + bcrypt (~> 3.1.7) coffee-rails (~> 4.0.0) jbuilder (~> 2.0) jquery-rails diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e..ac9344b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,10 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + + def current_user + @current_user ||= User.find(session[:user_id]) if session[:user_id] + end + + helper_method :current_user end diff --git a/app/models/hacker.rb b/app/models/hacker.rb index c760509..1238654 100644 --- a/app/models/hacker.rb +++ b/app/models/hacker.rb @@ -1,2 +1,3 @@ -class Hacker < ActiveRecord::Base +class Hacker < ActiveRecord::Base + validates_presence_of :password, :on => :create end diff --git a/app/models/user.rb b/app/models/user.rb index 4a57cf0..8a68162 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,2 +1,7 @@ class User < ActiveRecord::Base + has_secure_password + has_many :responses + has_many :questions + has_many :answers + has_many :messages end diff --git a/app/views/hackers/_form.html.erb b/app/views/hackers/_form.html.erb index 372d2ac..c2e3969 100644 --- a/app/views/hackers/_form.html.erb +++ b/app/views/hackers/_form.html.erb @@ -19,6 +19,10 @@ <%= f.label :password %>
<%= f.text_field :password %> +
+ <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation %> +
<%= f.label :first_name %>
<%= f.text_field :first_name %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 947b671..41a263e 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -56,7 +56,11 @@ Password:
Subject: Question:
<% @questions.each do |question| %> + @@ -99,7 +104,6 @@ Password:
<%= session[:id] %> <%= question.id %> <%= question.creator_id %> <%= question.title %>

- diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 9c57c90..776f17c 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -11,10 +11,6 @@ <% end %> -
- <%= f.label :user_id %>
- <%= f.number_field :user_id %> -
<%= f.label :username %>
<%= f.text_field :username %> @@ -22,7 +18,7 @@
<%= f.label :password %>
<%= f.text_field :password %> -
+
<%= f.label :first_name %>
<%= f.text_field :first_name %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 9337a7d..66546a0 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -17,7 +17,7 @@ <% @users.each do |user| %> - <%= user.user_id %> + <%= user.id %> <%= user.username %> <%= user.password %> <%= user.first_name %> diff --git a/config/routes.rb b/config/routes.rb index 5bfdf83..4f4b526 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,11 @@ Rails.application.routes.draw do + resources :sessions do + end + + controller :logout do + get 'logout' => :destroy + end + resources :hackers resources :answers do diff --git a/db/schema.rb b/db/schema.rb index adc9070..374f3d6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20141020233116) do +ActiveRecord::Schema.define(version: 20141130112227) do create_table "answers", force: true do |t| t.integer "question_id" @@ -85,6 +85,11 @@ t.datetime "updated_at" end + create_table "sessions", force: true do |t| + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "users", force: true do |t| t.integer "user_id" t.string "username" @@ -95,6 +100,7 @@ t.integer "type" t.datetime "created_at" t.datetime "updated_at" + t.string "password_digest" end end From 247158360c647497372737108b23854913946f91 Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Sun, 30 Nov 2014 07:19:44 -0600 Subject: [PATCH 32/51] commit 2 --- app/assets/javascripts/logout.js.coffee | 3 ++ app/assets/javascripts/sessions.js.coffee | 3 ++ app/assets/stylesheets/logout.css.scss | 3 ++ app/assets/stylesheets/sessions.css.scss | 3 ++ app/controllers/logout_controller.rb | 22 +++++++++ app/controllers/sessions_controller.rb | 23 +++++++++ app/helpers/logout_helper.rb | 2 + app/helpers/sessions_helper.rb | 5 ++ app/models/session.rb | 2 + app/views/hackers/login.html.erb | 30 ++++++++++++ app/views/questions/index.html.erb | 2 +- app/views/sessions/_form.html.erb | 17 +++++++ app/views/sessions/edit.html.erb | 6 +++ app/views/sessions/index.html.erb | 5 ++ app/views/sessions/index.json.jbuilder | 4 ++ app/views/sessions/new.html.erb | 17 +++++++ app/views/sessions/show.html.erb | 4 ++ app/views/sessions/show.json.jbuilder | 1 + db/migrate/20141129223728_create_sessions.rb | 8 +++ ...1130112227_add_password_digest_to_users.rb | 5 ++ test/controllers/logout_controller_test.rb | 7 +++ test/controllers/sessions_controller_test.rb | 49 +++++++++++++++++++ test/fixtures/sessions.yml | 11 +++++ test/helpers/logout_helper_test.rb | 4 ++ test/helpers/sessions_helper_test.rb | 4 ++ test/models/session_test.rb | 7 +++ 26 files changed, 246 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/logout.js.coffee create mode 100644 app/assets/javascripts/sessions.js.coffee create mode 100644 app/assets/stylesheets/logout.css.scss create mode 100644 app/assets/stylesheets/sessions.css.scss create mode 100644 app/controllers/logout_controller.rb create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/helpers/logout_helper.rb create mode 100644 app/helpers/sessions_helper.rb create mode 100644 app/models/session.rb create mode 100644 app/views/hackers/login.html.erb create mode 100644 app/views/sessions/_form.html.erb create mode 100644 app/views/sessions/edit.html.erb create mode 100644 app/views/sessions/index.html.erb create mode 100644 app/views/sessions/index.json.jbuilder create mode 100644 app/views/sessions/new.html.erb create mode 100644 app/views/sessions/show.html.erb create mode 100644 app/views/sessions/show.json.jbuilder create mode 100644 db/migrate/20141129223728_create_sessions.rb create mode 100644 db/migrate/20141130112227_add_password_digest_to_users.rb create mode 100644 test/controllers/logout_controller_test.rb create mode 100644 test/controllers/sessions_controller_test.rb create mode 100644 test/fixtures/sessions.yml create mode 100644 test/helpers/logout_helper_test.rb create mode 100644 test/helpers/sessions_helper_test.rb create mode 100644 test/models/session_test.rb diff --git a/app/assets/javascripts/logout.js.coffee b/app/assets/javascripts/logout.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/logout.js.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/app/assets/javascripts/sessions.js.coffee b/app/assets/javascripts/sessions.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/sessions.js.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/app/assets/stylesheets/logout.css.scss b/app/assets/stylesheets/logout.css.scss new file mode 100644 index 0000000..56a0eae --- /dev/null +++ b/app/assets/stylesheets/logout.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the logout controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sessions.css.scss b/app/assets/stylesheets/sessions.css.scss new file mode 100644 index 0000000..ccb1ed2 --- /dev/null +++ b/app/assets/stylesheets/sessions.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Sessions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/logout_controller.rb b/app/controllers/logout_controller.rb new file mode 100644 index 0000000..f6b9040 --- /dev/null +++ b/app/controllers/logout_controller.rb @@ -0,0 +1,22 @@ +class LogoutController < ApplicationController + def new + @session = Session.new + end + + def create + user = User.find_by_username(params[:username]) + if user && user.authenticate(params[:password]) + session[:id] = user.id + reset_session + redirect_to root_url, :notice => "Logged in!" + else + flash.now.alert = "Invalid email or password" + render "new" + end + end + + def destroy + session.delete(:id) + redirect_to root_url, :notice => "Logged out!" + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000..03fbb98 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,23 @@ +class SessionsController < ApplicationController + def new + end + def new + @session = Session.new + end + + def create + user = User.find_by_username(params[:username]) + if user && user.authenticate(params[:password]) + session[:id] = user.id + redirect_to root_url, :notice => "Logged in!" + else + flash.now.alert = "Invalid email or password" + render "new" + end + end + + def destroy + session.delete(:id) + redirect_to root_url, :notice => "Logged out!" + end +end \ No newline at end of file diff --git a/app/helpers/logout_helper.rb b/app/helpers/logout_helper.rb new file mode 100644 index 0000000..b1bf445 --- /dev/null +++ b/app/helpers/logout_helper.rb @@ -0,0 +1,2 @@ +module LogoutHelper +end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 0000000..17b74f1 --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,5 @@ +module SessionsHelper + def destroy_session + session.destroy + end +end diff --git a/app/models/session.rb b/app/models/session.rb new file mode 100644 index 0000000..54fee45 --- /dev/null +++ b/app/models/session.rb @@ -0,0 +1,2 @@ +class Session < ActiveRecord::Base +end diff --git a/app/views/hackers/login.html.erb b/app/views/hackers/login.html.erb new file mode 100644 index 0000000..37f4f79 --- /dev/null +++ b/app/views/hackers/login.html.erb @@ -0,0 +1,30 @@ +

login

+ +<%= form_for(@hacker) do |f| %> + <% if @hacker.errors.any? %> +
+

<%= pluralize(@hacker.errors.count, "error") %> prohibited this hacker from being saved:

+ +
    + <% @hacker.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :username %>
+ <%= f.text_field :username %> +
+
+ <%= f.label :password %>
+ <%= f.text_field :password %> +
+
+ <%= f.submit %> +
+<% end %> + + +<%= link_to 'Back', hackers_path %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 41a263e..8adafc9 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -82,7 +82,7 @@ Password: <% @questions.each do |question| %> - <%= session[:id] %> + <%= session[:id] %>--> <%= question.id %> <%= question.creator_id %> <%= question.title %> diff --git a/app/views/sessions/_form.html.erb b/app/views/sessions/_form.html.erb new file mode 100644 index 0000000..ad76797 --- /dev/null +++ b/app/views/sessions/_form.html.erb @@ -0,0 +1,17 @@ +<%= form_for(@session) do |f| %> + <% if @session.errors.any? %> +
+

<%= pluralize(@session.errors.count, "error") %> prohibited this session from being saved:

+ +
    + <% @session.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/sessions/edit.html.erb b/app/views/sessions/edit.html.erb new file mode 100644 index 0000000..bbd8407 --- /dev/null +++ b/app/views/sessions/edit.html.erb @@ -0,0 +1,6 @@ +

Editing session

+ +<%= render 'form' %> + +<%= link_to 'Show', @session %> | +<%= link_to 'Back', sessions_path %> diff --git a/app/views/sessions/index.html.erb b/app/views/sessions/index.html.erb new file mode 100644 index 0000000..637c079 --- /dev/null +++ b/app/views/sessions/index.html.erb @@ -0,0 +1,5 @@ +

Listing sessions

+ +
+ +<%= link_to 'New Session', new_session_path %> diff --git a/app/views/sessions/index.json.jbuilder b/app/views/sessions/index.json.jbuilder new file mode 100644 index 0000000..8d865db --- /dev/null +++ b/app/views/sessions/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@sessions) do |session| + json.extract! session, :id + json.url session_url(session, format: :json) +end diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 0000000..a4bfe68 --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,17 @@ +

New session

+ +

Log in

+ +<%= form_tag sessions_path do %> +
+ <%= label_tag :username %> + <%= text_field_tag :username, params[:username] %> +
+
+ <%= label_tag :password %> + <%= password_field_tag :password %> +
+
<%= submit_tag "Log in" %>
+<% end %> + +<%= link_to 'Back', sessions_path %> diff --git a/app/views/sessions/show.html.erb b/app/views/sessions/show.html.erb new file mode 100644 index 0000000..5e8ceb0 --- /dev/null +++ b/app/views/sessions/show.html.erb @@ -0,0 +1,4 @@ +

<%= notice %>

+ +<%= link_to 'Edit', edit_session_path(@session) %> | +<%= link_to 'Back', sessions_path %> diff --git a/app/views/sessions/show.json.jbuilder b/app/views/sessions/show.json.jbuilder new file mode 100644 index 0000000..8cfb72c --- /dev/null +++ b/app/views/sessions/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @session, :id, :created_at, :updated_at diff --git a/db/migrate/20141129223728_create_sessions.rb b/db/migrate/20141129223728_create_sessions.rb new file mode 100644 index 0000000..96e28b9 --- /dev/null +++ b/db/migrate/20141129223728_create_sessions.rb @@ -0,0 +1,8 @@ +class CreateSessions < ActiveRecord::Migration + def change + create_table :sessions do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20141130112227_add_password_digest_to_users.rb b/db/migrate/20141130112227_add_password_digest_to_users.rb new file mode 100644 index 0000000..7ad1f62 --- /dev/null +++ b/db/migrate/20141130112227_add_password_digest_to_users.rb @@ -0,0 +1,5 @@ +class AddPasswordDigestToUsers < ActiveRecord::Migration + def change + add_column :users, :password_digest, :string + end +end diff --git a/test/controllers/logout_controller_test.rb b/test/controllers/logout_controller_test.rb new file mode 100644 index 0000000..5857074 --- /dev/null +++ b/test/controllers/logout_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class LogoutControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 0000000..6074b20 --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class SessionsControllerTest < ActionController::TestCase + setup do + @session = sessions(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:sessions) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create session" do + assert_difference('Session.count') do + post :create, session: { } + end + + assert_redirected_to session_path(assigns(:session)) + end + + test "should show session" do + get :show, id: @session + assert_response :success + end + + test "should get edit" do + get :edit, id: @session + assert_response :success + end + + test "should update session" do + patch :update, id: @session, session: { } + assert_redirected_to session_path(assigns(:session)) + end + + test "should destroy session" do + assert_difference('Session.count', -1) do + delete :destroy, id: @session + end + + assert_redirected_to sessions_path + end +end diff --git a/test/fixtures/sessions.yml b/test/fixtures/sessions.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/sessions.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/helpers/logout_helper_test.rb b/test/helpers/logout_helper_test.rb new file mode 100644 index 0000000..ae65bd2 --- /dev/null +++ b/test/helpers/logout_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class LogoutHelperTest < ActionView::TestCase +end diff --git a/test/helpers/sessions_helper_test.rb b/test/helpers/sessions_helper_test.rb new file mode 100644 index 0000000..7d44e09 --- /dev/null +++ b/test/helpers/sessions_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class SessionsHelperTest < ActionView::TestCase +end diff --git a/test/models/session_test.rb b/test/models/session_test.rb new file mode 100644 index 0000000..2d1bc1b --- /dev/null +++ b/test/models/session_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SessionTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 578683420936b8a82f514bf3b5746700db2b3f03 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 30 Nov 2014 17:59:37 -0600 Subject: [PATCH 33/51] points sort of working --- app/controllers/answers_controller.rb | 5 ++++- app/controllers/users_controller.rb | 1 + app/views/questions/_form.html.erb | 2 +- app/views/questions/index.html.erb | 14 ++++++++------ db/schema.rb | 1 - 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index e759c79..d60263e 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -25,7 +25,7 @@ def edit # POST /answers.json def create @answer = Answer.new(answer_params) - + @answer.creator_id = session[:id] respond_to do |format| if @answer.save format.html { redirect_to @answer, notice: 'Answer was successfully created.' } @@ -70,6 +70,9 @@ def correct @question = Question.find(@answer.q_response_id) @question.toggle!(:answered) + @user = User.find(@answer.creator_id) + @user.score = @user.score+1 + @user.save @answer.save @question.save end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8441ffe..828a184 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -15,6 +15,7 @@ def show # GET /users/new def new @user = User.new + end # GET /users/1/edit diff --git a/app/views/questions/_form.html.erb b/app/views/questions/_form.html.erb index 78637d1..68b92a4 100644 --- a/app/views/questions/_form.html.erb +++ b/app/views/questions/_form.html.erb @@ -17,7 +17,7 @@ content : <%= f.text_area(:content, size: '50x10') %>
<%=f.hidden_field :question_id, :value => 123 %> -<%=f.hidden_field :creator_id, :value => 100 %> +<%=f.hidden_field :creator_id, :value => session[:id] %> <%=f.hidden_field :answered, :value => false %> <%=f.hidden_field :timestamp, :value => DateTime.now %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 8adafc9..3be99b1 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -1,3 +1,4 @@ + @@ -5,17 +6,17 @@ - -
 Username: 
 Password: 
 
-
- +--> <%= session[:id] %>--> <%= question.id %> - <%= question.creator_id %> + <%= question.creator_id %> + + <%= question.title %> <%= question.content %> <%= question.category %> diff --git a/db/schema.rb b/db/schema.rb index 374f3d6..53b4013 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,7 +14,6 @@ ActiveRecord::Schema.define(version: 20141130112227) do create_table "answers", force: true do |t| - t.integer "question_id" t.integer "answer_id" t.integer "q_response_id" t.integer "creator_id" From c3e7bceaca669aa68fe8c43a895a170f26fff263 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 30 Nov 2014 19:36:10 -0600 Subject: [PATCH 34/51] points working better --- app/controllers/users_controller.rb | 2 +- app/views/answers/index.html.erb | 4 +- app/views/home/index.html.erb | 102 +++++++++++++++++----------- app/views/questions/_form.html.erb | 2 +- app/views/questions/index.html.erb | 5 +- app/views/questions/show.html.erb | 2 +- 6 files changed, 72 insertions(+), 45 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 828a184..e113002 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -15,7 +15,7 @@ def show # GET /users/new def new @user = User.new - + @user.score=0 end # GET /users/1/edit diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb index d3f3c8e..7526cf6 100644 --- a/app/views/answers/index.html.erb +++ b/app/views/answers/index.html.erb @@ -23,11 +23,13 @@ <%= answer.content %> <%= answer.timestamp %> <%= link_to 'Show', answer %> + <%= link_to 'Edit', edit_answer_path(answer) %> <%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %> <%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %> + <%= link_to 'Correct', correct_answer_path(answer)%> - + <% end %> diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 24e379e..5480d7f 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,46 +1,70 @@ - - - - + - - + - question - - + - + - - - - +<%= link_to 'log in', new_session_path %> +<%= link_to 'log out', logout_path %> - -
-
-

question

-
- +<%= link_to 'New Question', new_question_path %> + + +<% @questions.each do |question| %> + + + + + + + +
<%= question.creator_id %>  
+ + + + + +
Question +

<%=question.content%>

+<% end %> + + + + + + + + +
Username  
+ + + + + +
Question +

Questions?Question?Question?

+ + + + + + + + + +
Username  
+ + + + + + + +
Question +

Questions?Question?Question?

+ + -
- -
- -
-

- © Copyright by Seth -

-
-
- diff --git a/app/views/questions/_form.html.erb b/app/views/questions/_form.html.erb index 68b92a4..897e056 100644 --- a/app/views/questions/_form.html.erb +++ b/app/views/questions/_form.html.erb @@ -16,7 +16,7 @@ category: <%= f.select :category, options_for_select(%w[1 2 3 4 5]) %>
content : <%= f.text_area(:content, size: '50x10') %>
-<%=f.hidden_field :question_id, :value => 123 %> + <%=f.hidden_field :creator_id, :value => session[:id] %> <%=f.hidden_field :answered, :value => false %> <%=f.hidden_field :timestamp, :value => DateTime.now %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 3be99b1..95b3670 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -78,8 +78,9 @@ Password: - + --> + <% @questions.each do |question| %> @@ -116,7 +117,7 @@ Password: - + diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index c3ec54d..c866749 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -2,7 +2,7 @@

Question: - <%= @question.question_id %> + <%= @question.id %>

From 2bf28948fd6e8fa4ea341bd89ebd325fa206d722 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 30 Nov 2014 19:51:04 -0600 Subject: [PATCH 35/51] question index updates --- app/views/questions/index.html.erb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 95b3670..2719264 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -126,8 +126,15 @@ Password:

+ + + + + + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> +
<%= question.creator_id %> <%= link_to question.id, question %>  
Question

<%=question.content%>

<% end %> @@ -144,6 +151,7 @@ Password: Question

Questions?Question?Question?

+ From 32846f901851de05542780c426c4b027a8aabfdf Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 30 Nov 2014 19:53:38 -0600 Subject: [PATCH 36/51] questions index updated again --- app/views/questions/index.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 2719264..a8c0fb1 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -133,7 +133,9 @@ Password: + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> + <% end %> From 3a96a75dd0eb40ac16567829e77324a924f1dcd2 Mon Sep 17 00:00:00 2001 From: fabetron Date: Sun, 30 Nov 2014 19:56:54 -0600 Subject: [PATCH 37/51] validates passwords --- app/models/user.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 8a68162..fc7f635 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,4 +4,6 @@ class User < ActiveRecord::Base has_many :questions has_many :answers has_many :messages + validates_uniqueness_of :username + validates_presence_of :password end From ad1f72057d7387ccebc17a3e3c76f95e1aa62688 Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Sun, 30 Nov 2014 20:48:51 -0600 Subject: [PATCH 38/51] login required --- app/controllers/application_controller.rb | 10 ++++++++++ app/controllers/logout_controller.rb | 3 +++ app/controllers/sessions_controller.rb | 2 ++ app/views/answers/_form.html.erb | 3 +-- app/views/answers/index.html.erb | 5 +++++ app/views/questions/index.html.erb | 2 +- app/views/responses/_form.html.erb | 3 +-- app/views/responses/index.html.erb | 4 ++++ 8 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ac9344b..ada5c82 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,4 +8,14 @@ def current_user end helper_method :current_user + + before_filter :require_login + +private + + def require_login + unless session[:id] + redirect_to new_session_path + end + end end diff --git a/app/controllers/logout_controller.rb b/app/controllers/logout_controller.rb index f6b9040..48b416c 100644 --- a/app/controllers/logout_controller.rb +++ b/app/controllers/logout_controller.rb @@ -3,6 +3,9 @@ def new @session = Session.new end + + skip_before_filter :require_login + def create user = User.find_by_username(params[:username]) if user && user.authenticate(params[:password]) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 03fbb98..471d06d 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -5,6 +5,8 @@ def new @session = Session.new end + skip_before_filter :require_login + def create user = User.find_by_username(params[:username]) if user && user.authenticate(params[:password]) diff --git a/app/views/answers/_form.html.erb b/app/views/answers/_form.html.erb index 78c7de2..5c91a0a 100644 --- a/app/views/answers/_form.html.erb +++ b/app/views/answers/_form.html.erb @@ -18,8 +18,7 @@
<%= f.submit %>
- <%=f.hidden_field :response_id, :value => 456 %> - <%=f.hidden_field :creator_id, :value => 100 %> + <%=f.hidden_field :creator_id, :value => session[:id] %> <%=f.hidden_field :response_score, :value => 0 %> <%=f.hidden_field :timestamp, :value => DateTime.now %> <%=f.hidden_field :q_response_id, :value => params[:question_id] %> diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb index 7526cf6..71a0185 100644 --- a/app/views/answers/index.html.erb +++ b/app/views/answers/index.html.erb @@ -1,3 +1,8 @@ + +<%= link_to 'log out', logout_path %> + +

+

Listing answers

diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index a8c0fb1..25ce46f 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -57,7 +57,7 @@ Password:
Subject: Question: <%= f.submit %> - <%=f.hidden_field :response_id, :value => 456 %> - <%=f.hidden_field :creator_id, :value => 100 %> + <%=f.hidden_field :creator_id, :value => session[:id] %> <%=f.hidden_field :response_score, :value => 0 %> <%=f.hidden_field :timestamp, :value => DateTime.now %> <%=f.hidden_field :q_response_id, :value => params[:question_id] %> diff --git a/app/views/responses/index.html.erb b/app/views/responses/index.html.erb index 0213966..d48e184 100644 --- a/app/views/responses/index.html.erb +++ b/app/views/responses/index.html.erb @@ -1,3 +1,7 @@ + +<%= link_to 'log out', logout_path %> + +

Listing responses

From 594decf3383422bafa761c3e18803455e98cb85f Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Sun, 30 Nov 2014 20:54:41 -0600 Subject: [PATCH 39/51] new user accessible when logged out --- app/controllers/users_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e113002..221875b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,6 +7,8 @@ def index @users = User.all end + skip_before_filter :require_login + # GET /users/1 # GET /users/1.json def show From cc66af98c7ddc4c9469a217915ebeaf7dbed2416 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 30 Nov 2014 21:34:35 -0600 Subject: [PATCH 40/51] only can mark questions you made --- app/views/questions/index.html.erb | 4 ++-- app/views/questions/show.html.erb | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 25ce46f..e9617e1 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -117,8 +117,8 @@ Password:
- - + +
<%= link_to question.id, question %>   <%= link_to question.id, question %>  
diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index c866749..f16beee 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -64,12 +64,10 @@ - - - - - + <%if session[:id] == Question.find(answer.q_response_id).creator_id %> + + <%end %> <% end %> From 421a4973815dc5309e4ed5764aae38e6f8beb103 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 30 Nov 2014 21:57:34 -0600 Subject: [PATCH 41/51] users page functions as ranking autorefreshes every 60 seconds --- app/controllers/users_controller.rb | 2 +- app/views/users/index.html.erb | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 221875b..d58b73f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,7 +4,7 @@ class UsersController < ApplicationController # GET /users # GET /users.json def index - @users = User.all + @users = User.all.order(score: :desc) end skip_before_filter :require_login diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 66546a0..9cf21be 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,4 +1,7 @@ -

Listing users

+ + + + +
<%= answer.response_score %> <%= answer.content %> <%= answer.timestamp %><%= link_to 'Show', answer %><%= link_to 'Edit', edit_answer_path(answer) %><%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %> <%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= link_to 'Correct', correct_answer_path(answer)%><%= link_to 'Correct', correct_answer_path(answer)%>
+ + + + + + + + + + + <% @users.each do |user| %> + + + + + + <% end %> + +
UserUsernameScore
<%= user.id %><%= user.username %><%= user.score %>
\ No newline at end of file From 7292c7fb0c43483aa4f39f0c3feac3357d6e281a Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Sun, 30 Nov 2014 22:44:49 -0600 Subject: [PATCH 42/51] trying again --- app/views/answers/show.html.erb | 43 ++++----- app/views/questions/index.html.erb | 134 +++++++++++++++++++++++++++-- app/views/questions/show.html.erb | 47 +++++----- 3 files changed, 169 insertions(+), 55 deletions(-) diff --git a/app/views/answers/show.html.erb b/app/views/answers/show.html.erb index 57a0a90..a1f4d62 100644 --- a/app/views/answers/show.html.erb +++ b/app/views/answers/show.html.erb @@ -1,34 +1,35 @@

<%= notice %>

+

Answer: - <%= @answer.answer_id %> + <%= @answer.content %>

- Q response: - <%= @answer.q_response_id %> + Comments:

-

- Creator: - <%= @answer.creator_id %> -

+<% @responses.order('timestamp').reverse_order().take(3).each do |response| %> + + + + + + +
+ + + + + + + -

- Response score: - <%= @answer.response_score %> -

+ +

<%=response.content%>

-

- Content: - <%= @answer.content %> -

+
+<% end %> -

- Timestamp: - <%= @answer.timestamp %> -

-<%= link_to 'Edit', edit_answer_path(@answer) %> | -<%= link_to 'Back', answers_path %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index e9617e1..fe16031 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -111,21 +111,136 @@ Password: <%= link_to 'New Question', new_question_path %> - + +

Category 1

-<% @questions.each do |question| %> +<% @questions.where("category = '1'").order('timestamp').reverse_order().each do |question| %> - - + +
<%= link_to question.id, question %>   <%= link_to question.title, question %>  
- + + + + + + + + + + +
Question -

<%=question.content%>

<%=question.content%>

+ <%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%= " "%><%= link_to "Show All Answers", question %> +
+<% end %> + + +
+

Category 2

+<% @questions.where("category = '2'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + + + + + + + + + + +

<%=question.content%>

+ <%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%= " "%><%= link_to "Show All Answers", question %> +
+<% end %> + +
+

Category 3

+<% @questions.where("category = '3'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + + + + + + + + + + +

<%=question.content%>

+ <%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%= " "%><%= link_to "Show All Answers", question %> +
+<% end %> + +
+

Category 4

+<% @questions.where("category = '4'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + + + + + + + + + + +

<%=question.content%>

+ <%= link_to "Show Answers", question %>
+ <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> +
+<% end %> + +
+

Category 5

+<% @questions.where("category = '5'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + @@ -140,7 +255,7 @@ Password:

<%=question.content%>

+ <%= link_to "Show Answers", question %>
<% end %> - + -
+ - - + <% if session[:id] == Question.find(answer.q_response_id).creator_id %> - + <% end %> <% end %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 2bf40bf..3cecc6f 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -121,7 +121,7 @@ Password: - +
Question + diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index f16beee..68fab73 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -42,33 +42,30 @@ <%= link_to 'Edit', edit_question_path(@question) %> | <%= link_to 'Back', questions_path %> - - + + + <% @answers.where("q_response_id = '" + @question.id.to_s + "'").each do |answer| %> +
+ - - - - - - - + - -
AnswerQ responseCreatorResponse scoreContentTimestamp
+ +
- <% @answers.each do |answer| %> - - - - - - - - - <%if session[:id] == Question.find(answer.q_response_id).creator_id %> - - <%end %> - - <% end %> + + + + + + + + + +
<%= answer.id %><%= answer.q_response_id %><%= answer.creator_id %><%= answer.response_score %><%= answer.content %><%= answer.timestamp %><%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= link_to 'Correct', correct_answer_path(answer)%>

<%=answer.content%>

<%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= " "%><%= link_to "Show All Comments", answer %>
+ +
+<% end %> + From efd5cb31f1250439f351616bf831e9dd7940a62c Mon Sep 17 00:00:00 2001 From: Travis91 Date: Sun, 30 Nov 2014 23:30:10 -0600 Subject: [PATCH 43/51] added more ui stuff --- app/views/questions/index.html.erb | 2 +- app/views/sessions/new.html.erb | 2 +- app/views/users/_form.html.erb | 8 -------- app/views/users/index.html.erb | 4 ++-- app/views/users/new.html.erb | 2 +- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index fe16031..12266f7 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -59,7 +59,7 @@ Password: Question:<%= submit_tag "Log in" %> <% end %> - +<%= link_to 'New User', new_user_path %> <%= link_to 'Back', sessions_path %> diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 776f17c..4b1ac14 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -27,14 +27,6 @@ <%= f.label :last_name %>
<%= f.text_field :last_name %> -
- <%= f.label :score %>
- <%= f.number_field :score %> -
-
- <%= f.label :type %>
- <%= f.number_field :type %> -
<%= f.submit %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 9cf21be..6a96ccd 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,7 +1,7 @@ - + diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index efc0404..17c898d 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -2,4 +2,4 @@ <%= render 'form' %> -<%= link_to 'Back', users_path %> +<%= link_to 'Back', sessions_path %> From a54954a1a57e5f5f0f769017c1e1563c5cf170e2 Mon Sep 17 00:00:00 2001 From: sonicseth2000 Date: Mon, 1 Dec 2014 00:41:04 -0600 Subject: [PATCH 44/51] cleaned and responses added --- app/controllers/answers_controller.rb | 6 +++++- app/helpers/answers_helper.rb | 4 ++++ app/models/question.rb | 1 + app/models/response.rb | 1 + app/views/answers/show.html.erb | 10 ++-------- app/views/questions/index.html.erb | 3 ++- app/views/questions/show.html.erb | 20 +++++++++++++++----- app/views/sessions/new.html.erb | 4 ++-- config/routes.rb | 3 ++- 9 files changed, 34 insertions(+), 18 deletions(-) diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index d60263e..44d5cb7 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -1,11 +1,15 @@ class AnswersController < ApplicationController before_action :set_answer, only: [:show, :edit, :update, :destroy] - + before_action :list # GET /answers # GET /answers.json def index @answers = Answer.all end + + def list + @responses = Response.all + end # GET /answers/1 # GET /answers/1.json diff --git a/app/helpers/answers_helper.rb b/app/helpers/answers_helper.rb index 66727e9..2bbb30d 100644 --- a/app/helpers/answers_helper.rb +++ b/app/helpers/answers_helper.rb @@ -1,5 +1,9 @@ module AnswersHelper + def list + @responses = Response.all + end def answer_question(answer) return "" end + end diff --git a/app/models/question.rb b/app/models/question.rb index 50ffaec..f7c7ebd 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,5 +1,6 @@ class Question < ActiveRecord::Base has_many :answers +has_many :responses validates_uniqueness_of :content validates_uniqueness_of :title validates_presence_of :content diff --git a/app/models/response.rb b/app/models/response.rb index 28aea65..565b618 100644 --- a/app/models/response.rb +++ b/app/models/response.rb @@ -1,2 +1,3 @@ class Response < ActiveRecord::Base + belongs_to :questions end diff --git a/app/views/answers/show.html.erb b/app/views/answers/show.html.erb index a1f4d62..1749256 100644 --- a/app/views/answers/show.html.erb +++ b/app/views/answers/show.html.erb @@ -1,14 +1,8 @@ -

<%= notice %>

-

- Answer: - <%= @answer.content %> -

- -

+

Comments: -

+

<% @responses.order('timestamp').reverse_order().take(3).each do |response| %>
diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 12266f7..82f43e3 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -6,6 +6,7 @@ + + diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 68fab73..7627c8c 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -1,4 +1,4 @@ -

<%= notice %>

+ + +

+ + <%= @question.title %> +

- Content: + Question: <%= @question.content %>

-

+

+ Answers: +

+ <% @answers.where("q_response_id = '" + @question.id.to_s + "'").each do |answer| %>
@@ -69,3 +77,5 @@
<% end %> +<%= link_to 'Back', questions_path %> + diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index e0161fc..e17629b 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,4 +1,4 @@ -

New session

+

Log in

@@ -14,4 +14,4 @@
<%= submit_tag "Log in" %>
<% end %> <%= link_to 'New User', new_user_path %> -<%= link_to 'Back', sessions_path %> + diff --git a/config/routes.rb b/config/routes.rb index 4f4b526..0d597df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,7 +9,8 @@ resources :hackers resources :answers do - get 'correct', :on => :member + get 'correct', :on => :member + resources :responses end root 'questions#index' From 95fdcc4299378fa8a17e89788009384fcbf8cf2e Mon Sep 17 00:00:00 2001 From: Travis91 Date: Mon, 1 Dec 2014 09:14:19 -0600 Subject: [PATCH 45/51] not much changed --- app/views/users/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 6a96ccd..258efb7 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -2,7 +2,7 @@

Listing users

- + <%= link_to 'New User', new_user_path %>
From ad409ac02105e7b16aec8bb8219cb74a7f6d5db2 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Mon, 1 Dec 2014 10:45:35 -0600 Subject: [PATCH 46/51] added answered button to question page --- app/views/questions/index.html.erb | 1 + app/views/questions/show.html.erb | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 82f43e3..2bf40bf 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -82,6 +82,7 @@ Password: + <% @questions.each do |question| %> diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 7627c8c..b9b2922 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -55,9 +55,6 @@ <% @answers.where("q_response_id = '" + @question.id.to_s + "'").each do |answer| %>
- - -
@@ -71,6 +68,10 @@ + + + +
<%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= " "%><%= link_to "Show All Comments", answer %>
<%= link_to 'Correct', correct_answer_path(answer)%>
From 45b731b84b70e56d21910fa2fc9729e3b34a7d68 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Mon, 1 Dec 2014 11:16:08 -0600 Subject: [PATCH 47/51] updated ui --- app/controllers/users_controller.rb | 5 +++-- app/views/answers/index.html.erb | 4 ++-- app/views/questions/index.html.erb | 12 ++++++------ app/views/questions/show.html.erb | 6 +++++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d58b73f..54defaf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -17,7 +17,8 @@ def show # GET /users/new def new @user = User.new - @user.score=0 + + end # GET /users/1/edit @@ -28,7 +29,7 @@ def edit # POST /users.json def create @user = User.new(user_params) - + @user.score=0 respond_to do |format| if @user.save format.html { redirect_to @user, notice: 'User was successfully created.' } diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb index 71a0185..2fc3fda 100644 --- a/app/views/answers/index.html.erb +++ b/app/views/answers/index.html.erb @@ -32,9 +32,9 @@
<%= link_to 'Edit', edit_answer_path(answer) %> <%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %> <%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= link_to 'Correct', correct_answer_path(answer)%>
<%= link_to question.title, question %>    
@@ -150,7 +150,7 @@ Password: - +
<%= link_to question.title, question %>    
@@ -178,7 +178,7 @@ Password: - +
<%= link_to question.title, question %>    
@@ -206,7 +206,7 @@ Password: - +
<%= link_to question.title, question %>    
@@ -235,7 +235,7 @@ Password: - +
<%= link_to question.title, question %>    
@@ -243,7 +243,7 @@ Password: - + diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index b9b2922..5e42d7e 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -70,9 +70,13 @@ + <% if session[:id] == Question.find(answer.q_response_id).creator_id %> + - + + <%end%> +

<%=question.content%>

<%= link_to "Show Answers", question %>
<%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= " "%><%= link_to "Show All Comments", answer %>
<%= link_to 'Correct', correct_answer_path(answer)%>

From 11d306a51a218a6b833b5a763adf7f8752bb50c3 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Mon, 1 Dec 2014 15:44:26 -0600 Subject: [PATCH 48/51] updated views --- app/controllers/answers_controller.rb | 3 +- app/views/questions/index.html.erb | 75 ++++++++++++++++++++------- app/views/questions/show.html.erb | 3 ++ app/views/users/index.html.erb | 2 +- 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index 44d5cb7..676e2d8 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -32,13 +32,14 @@ def create @answer.creator_id = session[:id] respond_to do |format| if @answer.save - format.html { redirect_to @answer, notice: 'Answer was successfully created.' } + redirect_to(:back) format.json { render :show, status: :created, location: @answer } else format.html { render :new } format.json { render json: @answer.errors, status: :unprocessable_entity } end end + redirect_to(:back) end # PATCH/PUT /answers/1 diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 3cecc6f..31c4ad5 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -61,8 +61,9 @@ Password: <%= link_to 'log out', logout_path %> <%= link_to 'New User', new_user_path %> +<%= link_to 'Scores', users_path %>

- + - + + + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> + <%end%> <% end %> @@ -242,18 +272,27 @@ Password:

<%=question.content%>

- <%= link_to "Show Answers", question %> - + + - + + + <%= question.answered %> + + + + + <% if session[:id] != question.creator_id %> + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> + <%end%> <% end %> diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 5e42d7e..58e41d2 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -67,6 +67,7 @@ + <%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= " "%><%= link_to "Show All Comments", answer %> @@ -78,7 +79,9 @@ <%end%> +<% if session[:id] != @question.creator_id %> + <%= link_to 'Answer', new_answer_path(:question_id => @question.id) %><%end%>
<% end %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 258efb7..26da029 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,5 +1,5 @@ - +

Listing users

<%= link_to 'New Question', new_question_path %> From 7461d429ee41914a9b1d85b06e86e3f2cf1184b3 Mon Sep 17 00:00:00 2001 From: Travis91 Date: Mon, 1 Dec 2014 18:37:59 -0600 Subject: [PATCH 50/51] fixed format problem --- app/controllers/answers_controller.rb | 8 +++++--- app/views/questions/index.html.erb | 10 +++++----- app/views/questions/show.html.erb | 5 +++-- app/views/users/index.html.erb | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index 676e2d8..2d557f8 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -32,14 +32,14 @@ def create @answer.creator_id = session[:id] respond_to do |format| if @answer.save - redirect_to(:back) + format.html { redirect_to @answer, notice: 'Answer was successfully created.' } format.json { render :show, status: :created, location: @answer } else format.html { render :new } format.json { render json: @answer.errors, status: :unprocessable_entity } end end - redirect_to(:back) + end # PATCH/PUT /answers/1 @@ -72,11 +72,13 @@ def correct @answer = Answer.find(params[:id]) if @answer.response_score == 0 @answer.response_score = 1 - @question = Question.find(@answer.q_response_id) @question.toggle!(:answered) @user = User.find(@answer.creator_id) + p @user.username + "\n" + "\n" + p @user.score @user.score = @user.score+1 + p @user.score @user.save @answer.save @question.save diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 666fc6d..2a7de62 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -63,7 +63,7 @@ Password: <%= link_to 'New User', new_user_path %> <%= link_to 'Scores', users_path %>

- + - + <%= link_to 'New Question', new_question_path %> @@ -145,7 +145,7 @@ Password: <% if session[:id] != question.creator_id %> - <%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%end%><%= " "%> + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%end%> diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 58e41d2..9838622 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -79,11 +79,12 @@ <%end%> +
+
+<% end %> <% if session[:id] != @question.creator_id %> <%= link_to 'Answer', new_answer_path(:question_id => @question.id) %><%end%>
-<% end %> - <%= link_to 'Back', questions_path %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 26da029..a505219 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -2,7 +2,7 @@

Listing users

- + <%= link_to 'New User', new_user_path %> From 86067ea897d4255eccc911230021754e5b990efd Mon Sep 17 00:00:00 2001 From: Travis91 Date: Tue, 2 Dec 2014 13:17:48 -0600 Subject: [PATCH 51/51] i think it works --- app/controllers/answers_controller.rb | 7 +++---- app/controllers/users_controller.rb | 2 +- app/views/questions/show.html.erb | 4 ++-- db/migrate/20141013185823_create_questions.rb | 2 +- db/migrate/20141020220453_create_answers.rb | 1 + 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index 2d557f8..0195833 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -71,14 +71,13 @@ def destroy def correct @answer = Answer.find(params[:id]) if @answer.response_score == 0 + p "fuuuuuuuuuuuuuuuuuucccccccccccccckkkkkkkkkkkkkkkk" @answer.response_score = 1 @question = Question.find(@answer.q_response_id) @question.toggle!(:answered) @user = User.find(@answer.creator_id) - p @user.username + "\n" + "\n" - p @user.score - @user.score = @user.score+1 - p @user.score + @user.increment!(:score) + @user.save @answer.save @question.save diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 54defaf..8eea749 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -65,7 +65,7 @@ def destroy end end - private + # Use callbacks to share common setup or constraints between actions. def set_user @user = User.find(params[:id]) diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 9838622..860edc9 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -71,12 +71,12 @@ - <% if session[:id] == Question.find(answer.q_response_id).creator_id %> + - <%end%> +
<%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= " "%><%= link_to "Show All Comments", answer %>
<%= link_to 'Correct', correct_answer_path(answer)%>

diff --git a/db/migrate/20141013185823_create_questions.rb b/db/migrate/20141013185823_create_questions.rb index d64c112..2dcb237 100644 --- a/db/migrate/20141013185823_create_questions.rb +++ b/db/migrate/20141013185823_create_questions.rb @@ -2,7 +2,7 @@ class CreateQuestions < ActiveRecord::Migration def change create_table :questions do |t| - t.belong_to :question + t.integer :question_id t.integer :creator_id t.string :title diff --git a/db/migrate/20141020220453_create_answers.rb b/db/migrate/20141020220453_create_answers.rb index 2b221cf..0186710 100644 --- a/db/migrate/20141020220453_create_answers.rb +++ b/db/migrate/20141020220453_create_answers.rb @@ -1,6 +1,7 @@ class CreateAnswers < ActiveRecord::Migration def change create_table :answers do |t| + t.belongs_to :question t.integer :answer_id t.integer :q_response_id t.integer :creator_id