├── log
└── .gitkeep
├── lib
├── tasks
│ ├── .gitkeep
│ └── erd.rake
└── assets
│ └── .gitkeep
├── public
├── favicon.ico
├── partials
│ ├── home.html
│ ├── 404.html
│ ├── login.html
│ ├── questionFeed.html
│ ├── addTopic.html
│ ├── comment.html
│ ├── addQuestion.html
│ ├── topics.html
│ ├── topic.html
│ ├── question.html
│ ├── updateProfile.html
│ └── profile.html
├── robots.txt
├── scripts
│ ├── app.js
│ ├── config.js
│ ├── res
│ │ ├── angular-cookies.min.js
│ │ ├── angular-resource.min.js
│ │ ├── angular-route.min.js
│ │ ├── ng-file-upload-shim.min.js
│ │ ├── loading-bar.js
│ │ ├── angular-ui-router.min.js
│ │ └── ng-file-upload.min.js
│ └── controllers
│ │ ├── commentsController.js
│ │ ├── sessionsController.js
│ │ ├── questionsController.js
│ │ ├── topicsController.js
│ │ └── usersController.js
├── css
│ ├── app.css
│ └── loading-bar.css
└── index.html
├── test
├── unit
│ ├── .gitkeep
│ ├── user_test.rb
│ └── relationship_test.rb
├── fixtures
│ ├── .gitkeep
│ ├── relationships.yml
│ └── users.yml
├── functional
│ └── .gitkeep
├── integration
│ └── .gitkeep
├── performance
│ └── browsing_test.rb
└── test_helper.rb
├── app
├── models
│ ├── .gitkeep
│ ├── question_topic.rb
│ ├── comment.rb
│ ├── relationship.rb
│ ├── user_topic.rb
│ ├── answer.rb
│ ├── question.rb
│ ├── topic.rb
│ └── user.rb
├── views
│ └── api
│ │ └── v1
│ │ ├── users
│ │ ├── show.json.jbuilder
│ │ ├── index.json.jbuilder
│ │ └── _user.json.jbuilder
│ │ ├── topics
│ │ ├── show.json.jbuilder
│ │ ├── index.json.jbuilder
│ │ └── _topic.json.jbuilder
│ │ ├── answers
│ │ ├── show.json.jbuilder
│ │ ├── index.json.jbuilder
│ │ └── _answer.json.jbuilder
│ │ ├── sessions
│ │ └── show.json.jbuilder
│ │ ├── comments
│ │ ├── show.json.jbuilder
│ │ ├── index.json.jbuilder
│ │ └── _comment.json.jbuilder
│ │ └── questions
│ │ ├── show.json.jbuilder
│ │ ├── index.json.jbuilder
│ │ └── _question.json.jbuilder
└── controllers
│ ├── api
│ └── v1
│ │ ├── comments_controller.rb
│ │ ├── user_topics_controller.rb
│ │ ├── question_topics_controller.rb
│ │ ├── topics_controller.rb
│ │ ├── relationships_controller.rb
│ │ ├── answers_controller.rb
│ │ ├── users_controller.rb
│ │ ├── questions_controller.rb
│ │ └── sessions_controller.rb
│ └── application_controller.rb
├── vendor
├── plugins
│ └── .gitkeep
└── assets
│ ├── javascripts
│ └── .gitkeep
│ └── stylesheets
│ └── .gitkeep
├── erd.png
├── config.ru
├── config
├── environment.rb
├── boot.rb
├── initializers
│ ├── mime_types.rb
│ ├── backtrace_silencers.rb
│ ├── session_store.rb
│ ├── secret_token.rb
│ ├── wrap_parameters.rb
│ └── inflections.rb
├── locales
│ └── en.yml
├── routes.rb
├── database.yml
├── environments
│ ├── development.rb
│ ├── test.rb
│ └── production.rb
└── application.rb
├── db
├── migrate
│ ├── 20160304091425_add_password_digest_to_users.rb
│ ├── 20160304091724_add_remember_token_to_users.rb
│ ├── 20160304092602_create_topics.rb
│ ├── 20160304090930_create_users.rb
│ ├── 20160304091307_add_avatar_to_users.rb
│ ├── 20160304092313_create_questions.rb
│ ├── 20160304092524_create_comments.rb
│ ├── 20160304092441_create_answers.rb
│ ├── 20160304092647_create_user_topics.rb
│ ├── 20160304092624_create_question_topics.rb
│ └── 20160304093836_create_relationships.rb
├── seeds.rb
└── schema.rb
├── doc
└── README_FOR_APP
├── Rakefile
├── script
└── rails
├── README.md
├── Gemfile
├── .gitignore
└── Gemfile.lock
/log/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/unit/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/models/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/plugins/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/functional/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/integration/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/assets/javascripts/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/erd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ksashikumar/QuoraClone/HEAD/erd.png
--------------------------------------------------------------------------------
/app/views/api/v1/users/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.partial! "api/v1/users/user", user: @user
2 |
--------------------------------------------------------------------------------
/app/views/api/v1/topics/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.partial! 'api/v1/topics/topic', topic: @topic
2 |
--------------------------------------------------------------------------------
/app/views/api/v1/answers/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.partial! 'api/v1/answers/answer', answer: @answer
2 |
--------------------------------------------------------------------------------
/app/views/api/v1/sessions/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.partial! "api/v1/users/user", user: current_user
2 |
--------------------------------------------------------------------------------
/app/views/api/v1/comments/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.partial! 'api/v1/comments/comment', comment: @comment
2 |
--------------------------------------------------------------------------------
/app/views/api/v1/questions/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.partial! 'api/v1/questions/question', question: @question
2 |
--------------------------------------------------------------------------------
/app/views/api/v1/users/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.array! @users do |user|
2 | json.partial! 'api/v1/users/user', user: user
3 | end
4 |
--------------------------------------------------------------------------------
/app/views/api/v1/topics/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.array! @topics do |topic|
2 | json.partial! 'api/v1/topics/topic', topic: topic
3 | end
4 |
--------------------------------------------------------------------------------
/app/views/api/v1/answers/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.array! @answers do |answer|
2 | json.partial! 'api/v1/answers/answer', answer: answer
3 | end
4 |
--------------------------------------------------------------------------------
/app/views/api/v1/comments/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.array! @comments do |comment|
2 | json.partial! 'api/v1/comments/comment', comment: comment
3 | end
4 |
--------------------------------------------------------------------------------
/app/views/api/v1/questions/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.array! @questions do |question|
2 | json.partial! 'api/v1/questions/question', question: question
3 | end
4 |
5 |
--------------------------------------------------------------------------------
/test/unit/user_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UserTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/app/models/question_topic.rb:
--------------------------------------------------------------------------------
1 | class QuestionTopic < ActiveRecord::Base
2 | attr_accessible :question_id, :topic_id
3 |
4 | belongs_to :question
5 | belongs_to :topic
6 |
7 | end
8 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run QuoraClone::Application
5 |
--------------------------------------------------------------------------------
/test/unit/relationship_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class RelationshipTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/app/views/api/v1/comments/_comment.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! comment, :id, :body, :user_id, :answer_id, :updated_at
2 |
3 | json.user comment.user, :id, :first_name, :last_name, :email
4 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | QuoraClone::Application.initialize!
6 |
--------------------------------------------------------------------------------
/public/partials/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Welcome to QuoraClone
4 |
Made with Ruby on Rails and AngularJS
5 |
6 |
--------------------------------------------------------------------------------
/db/migrate/20160304091425_add_password_digest_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddPasswordDigestToUsers < ActiveRecord::Migration
2 | def change
3 | add_column :users, :password_digest, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 |
3 | # Set up gems listed in the Gemfile.
4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5 |
6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
7 |
--------------------------------------------------------------------------------
/doc/README_FOR_APP:
--------------------------------------------------------------------------------
1 | Use this README file to introduce your application and point to useful places in the API for learning more.
2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
3 |
--------------------------------------------------------------------------------
/db/migrate/20160304091724_add_remember_token_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddRememberTokenToUsers < ActiveRecord::Migration
2 | def change
3 | add_column :users, :remember_token, :string
4 | add_index :users, :remember_token
5 | end
6 | end
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-Agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/test/fixtures/relationships.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2 |
3 | one:
4 | follower_id: 1
5 | followed_id: 1
6 |
7 | two:
8 | follower_id: 1
9 | followed_id: 1
10 |
--------------------------------------------------------------------------------
/public/scripts/app.js:
--------------------------------------------------------------------------------
1 | angular.module('QuoraClone', ['ui.bootstrap', 'ngRoute', 'ngCookies', 'ngFileUpload', 'angular-loading-bar']);
2 | String.prototype.capitalize = function() {
3 | return this.charAt(0).toUpperCase() + this.slice(1);
4 | }
5 |
--------------------------------------------------------------------------------
/app/views/api/v1/topics/_topic.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! topic, :id, :title, :description
2 |
3 | json.questions do
4 | json.array! topic.questions do |question|
5 | json.partial! 'api/v1/questions/question', question: question
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/lib/tasks/erd.rake:
--------------------------------------------------------------------------------
1 | desc 'Generate Entity Relationship Diagram'
2 | task :generate_erd do
3 | system "erd --inheritance --filetype=dot --direct --attributes=foreign_keys,content"
4 | system "dot -Tpng erd.dot > erd.png"
5 | File.delete('erd.dot')
6 | end
--------------------------------------------------------------------------------
/db/migrate/20160304092602_create_topics.rb:
--------------------------------------------------------------------------------
1 | class CreateTopics < ActiveRecord::Migration
2 | def change
3 | create_table :topics do |t|
4 | t.string :title
5 | t.text :description
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/app/models/comment.rb:
--------------------------------------------------------------------------------
1 | class Comment < ActiveRecord::Base
2 | attr_accessible :body, :answer_id, :updated_at
3 |
4 | belongs_to :user, foreign_key: :user_id
5 | belongs_to :answer, foreign_key: :answer_id
6 |
7 | validates :body, :answer_id, presence: true
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20160304090930_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration
2 | def change
3 | create_table :users do |t|
4 | t.string :first_name
5 | t.string :last_name
6 | t.string :email
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/models/relationship.rb:
--------------------------------------------------------------------------------
1 | class Relationship < ActiveRecord::Base
2 | attr_accessible :followed_id
3 |
4 | belongs_to :follower, class_name: "User"
5 | belongs_to :followed, class_name: "User"
6 |
7 | validates :follower_id, presence: true
8 | validates :followed_id, presence: true
9 | end
--------------------------------------------------------------------------------
/app/models/user_topic.rb:
--------------------------------------------------------------------------------
1 | class UserTopic < ActiveRecord::Base
2 | attr_accessible :topic_id, :user_id
3 |
4 | belongs_to :user
5 | belongs_to :topic
6 |
7 | validates :user, :topic, presence: true
8 |
9 | validates_uniqueness_of :user_id, :scope => :topic_id
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20160304091307_add_avatar_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddAvatarToUsers < ActiveRecord::Migration
2 | def self.up
3 | change_table :users do |t|
4 | t.attachment :avatar
5 | end
6 | end
7 |
8 | def self.down
9 | drop_attached_file :users, :avatar
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/test/fixtures/users.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2 |
3 | one:
4 | first_name: MyString
5 | last_name: MyString
6 | email: MyString
7 |
8 | two:
9 | first_name: MyString
10 | last_name: MyString
11 | email: MyString
12 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env rake
2 | # Add your own tasks in files placed in lib/tasks ending in .rake,
3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4 |
5 | require File.expand_path('../config/application', __FILE__)
6 |
7 | QuoraClone::Application.load_tasks
8 |
--------------------------------------------------------------------------------
/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | APP_PATH = File.expand_path('../../config/application', __FILE__)
5 | require File.expand_path('../../config/boot', __FILE__)
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #Quora Clone - Minimal Version of Quora in Rails
2 |
3 | [Demo](http://52.33.191.220/)
4 |
5 | ## FEATURES:
6 |
7 | * Models: Question, Answer, Relationship, Comments, User, Topics
8 | * API design
9 | * AngularJS
10 |
11 | ## Domain Model
12 |
13 | 
14 |
15 | _Made with love for Quoara_ :heart:
--------------------------------------------------------------------------------
/app/views/api/v1/users/_user.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! user, :id, :first_name, :last_name, :email, :topic_ids, :followers, :followed_users
2 |
3 | json.topics do
4 | json.array! user.topics do |topic|
5 | json.partial! 'api/v1/topics/topic', topic: topic
6 | end
7 | end
8 |
9 | json.avatar user.avatar.url
10 | json.success "true"
11 |
--------------------------------------------------------------------------------
/app/models/answer.rb:
--------------------------------------------------------------------------------
1 | class Answer < ActiveRecord::Base
2 | attr_accessible :body, :question_id, :user_id, :votes
3 |
4 | belongs_to :user, foreign_key: :user_id
5 | belongs_to :question, foreign_key: :question_id
6 |
7 | has_many :comments, foreign_key: :answer_id
8 |
9 | validates :body, :question_id, presence: true
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/app/models/question.rb:
--------------------------------------------------------------------------------
1 | class Question < ActiveRecord::Base
2 | attr_accessible :description, :title, :votes, :user_id, :topics
3 |
4 | belongs_to :user, foreign_key: :user_id
5 |
6 | has_many :topics, :through => :question_topics
7 | has_many :question_topics
8 |
9 | has_many :answers
10 |
11 | validates :title, presence: true
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20160304092313_create_questions.rb:
--------------------------------------------------------------------------------
1 | class CreateQuestions < ActiveRecord::Migration
2 | def change
3 | create_table :questions do |t|
4 | t.text :title
5 | t.text :description
6 | t.integer :votes
7 | t.references :user
8 |
9 | t.timestamps
10 | end
11 | add_index :questions, :user_id
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20160304092524_create_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateComments < ActiveRecord::Migration
2 | def change
3 | create_table :comments do |t|
4 | t.text :body
5 | t.references :user
6 | t.references :answer
7 |
8 | t.timestamps
9 | end
10 | add_index :comments, :user_id
11 | add_index :comments, :answer_id
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7 | # Mayor.create(name: 'Emanuel', city: cities.first)
8 |
--------------------------------------------------------------------------------
/db/migrate/20160304092441_create_answers.rb:
--------------------------------------------------------------------------------
1 | class CreateAnswers < ActiveRecord::Migration
2 | def change
3 | create_table :answers do |t|
4 | t.text :body
5 | t.integer :votes
6 | t.references :user
7 | t.references :question
8 |
9 | t.timestamps
10 | end
11 | add_index :answers, :user_id
12 | add_index :answers, :question_id
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/app/models/topic.rb:
--------------------------------------------------------------------------------
1 | class Topic < ActiveRecord::Base
2 | attr_accessible :description, :title
3 |
4 | has_many :question_topics
5 | has_many :questions, :through => :question_topics
6 |
7 | has_many :user_topics
8 | has_many :users, through: :user_topics
9 |
10 | before_save do |topic|
11 | topic.title.downcase!
12 | end
13 |
14 | validates :title, presence: true, uniqueness: true
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20160304092647_create_user_topics.rb:
--------------------------------------------------------------------------------
1 | class CreateUserTopics < ActiveRecord::Migration
2 | def change
3 | create_table :user_topics do |t|
4 | t.references :user
5 | t.references :topic
6 |
7 | t.timestamps
8 | end
9 | add_index :user_topics, :user_id
10 | add_index :user_topics, :topic_id
11 | add_index :user_topics, [:user_id, :topic_id], unique: true
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/app/views/api/v1/answers/_answer.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! answer, :id, :body, :question_id, :user_id, :updated_at
2 |
3 | json.question answer.question, :id, :title, :description
4 |
5 | json.comments do
6 | json.array! answer.comments do |comment|
7 | json.partial! 'api/v1/comments/comment',
8 | comment: comment
9 | end
10 | end
11 |
12 | json.user answer.user, :id, :first_name, :last_name
13 |
14 | json.votes answer.votes
15 |
--------------------------------------------------------------------------------
/test/performance/browsing_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 | require 'rails/performance_test_help'
3 |
4 | class BrowsingTest < ActionDispatch::PerformanceTest
5 | # Refer to the documentation for all available options
6 | # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7 | # :output => 'tmp/performance', :formats => [:flat] }
8 |
9 | def test_homepage
10 | get '/'
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/db/migrate/20160304092624_create_question_topics.rb:
--------------------------------------------------------------------------------
1 | class CreateQuestionTopics < ActiveRecord::Migration
2 | def change
3 | create_table :question_topics do |t|
4 | t.references :question
5 | t.references :topic
6 |
7 | t.timestamps
8 | end
9 | add_index :question_topics, :question_id
10 | add_index :question_topics, :topic_id
11 | add_index :question_topics, [:question_id, :topic_id], unique: true
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20160304093836_create_relationships.rb:
--------------------------------------------------------------------------------
1 | class CreateRelationships < ActiveRecord::Migration
2 | def change
3 | create_table :relationships do |t|
4 | t.integer :follower_id
5 | t.integer :followed_id
6 |
7 | t.timestamps
8 | end
9 |
10 | add_index :relationships, :follower_id
11 | add_index :relationships, :followed_id
12 | add_index :relationships, [:follower_id, :followed_id], unique: true
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | gem 'rails', '3.2.18'
4 | gem 'mysql'
5 |
6 |
7 | group :assets do
8 | gem 'sass-rails', '~> 3.2.3'
9 | gem 'coffee-rails', '~> 3.2.1'
10 | gem 'uglifier', '>= 1.0.3'
11 | end
12 |
13 | gem 'jquery-rails'
14 | gem 'jbuilder'
15 | gem 'byebug'
16 | gem 'jquery-ui-rails'
17 | gem 'paperclip', '~> 4.1'
18 | gem 'strong_parameters'
19 | gem 'bcrypt-ruby', '3.0.1'
20 | gem 'rails-erd'
21 | gem 'brakeman', :require => false
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | QuoraClone::Application.config.session_store :cookie_store, key: '_QuoraClone_session'
4 |
5 | # Use the database for sessions instead of the cookie-based default,
6 | # which shouldn't be used to store highly confidential information
7 | # (create the session table with "rails generate session_migration")
8 | # QuoraClone::Application.config.session_store :active_record_store
9 |
--------------------------------------------------------------------------------
/app/views/api/v1/questions/_question.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! question, :id, :title, :description, :user_id, :updated_at
2 |
3 | json.user question.user, :id, :first_name, :last_name, :email
4 |
5 | json.answers do
6 | json.array! question.answers do |answer|
7 | json.partial! 'api/v1/answers/answer', answer: answer
8 | end
9 | end
10 |
11 | json.topics do
12 | json.array! question.topics do |topic|
13 | json.extract! topic, :id, :title, :description
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile ~/.gitignore_global
6 |
7 | # Ignore bundler config
8 | /.bundle
9 |
10 | # Ignore all logfiles and tempfiles.
11 | /log/*.log
12 | /tmp
13 |
14 | /public/system
15 |
16 | .byebug_history
17 | .DS_Store
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | ENV["RAILS_ENV"] = "test"
2 | require File.expand_path('../../config/environment', __FILE__)
3 | require 'rails/test_help'
4 |
5 | class ActiveSupport::TestCase
6 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7 | #
8 | # Note: You'll currently still have to declare fixtures explicitly in integration tests
9 | # -- they do not yet inherit this setting
10 | fixtures :all
11 |
12 | # Add more helper methods to be used by all tests here...
13 | end
14 |
--------------------------------------------------------------------------------
/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | QuoraClone::Application.config.secret_token = '29a04dd2d5a0ace95df583380d18e9e5286acfd26d83cc73f5d7459a1b6b1822a98e1f653240b6c9e0b4af9dd03a033c81127db4213526f8bbee76e3c28279bf'
8 |
--------------------------------------------------------------------------------
/public/partials/404.html:
--------------------------------------------------------------------------------
1 |
2 | The page you were looking for doesn't exist (404)
3 |
7 |
8 |
9 |
10 |
11 |
The page you were looking for doesn't exist.
12 |
You may have mistyped the address or the page may have moved.
13 |
14 |
15 |