A Stack Overflow-like Q&A platform built with Ruby on Rails where users can ask questions, provide answers, attach files, and mark the best answers.
- User authentication with Devise
- Ask and answer questions
- File attachments for questions and answers
- Mark best answer functionality
- Real-time updates with AJAX
- Responsive design with Slim templates
- Ruby: 2.7.2
- Rails: 5.2.3
- Database: PostgreSQL
- Authentication: Devise
- File Uploads: CarrierWave
- Templates: Slim
- JavaScript: CoffeeScript, jQuery
- Testing: RSpec, Capybara, Factory Bot
- Ruby 2.7.2
- PostgreSQL 9.5+
- Node.js (for asset compilation)
- Yarn
- Clone the repository:
git clone <repository-url>
cd qna- Install dependencies:
bundle install
yarn install- Setup database:
rails db:create
rails db:migrate
rails db:seed- Start the server:
rails server- Visit
http://localhost:3000
Configure your database connection in config/database.yml
Uploaded files are stored in public/uploads/ directory by default. Configure CarrierWave settings in app/uploaders/file_uploader.rb
Supported file types:
- Images: jpg, jpeg, gif, png
- Documents: pdf, doc, docx, txt
- Archives: zip, rar
Maximum file size: 10MB
Run the full test suite:
rspecRun specific test files:
rspec spec/models/question_spec.rb
rspec spec/controllers/questions_controller_spec.rbRun acceptance tests:
rspec spec/acceptance/This application can be deployed to Heroku, AWS, or any other Rails-compatible hosting platform.
heroku create
git push heroku master
heroku run rails db:migrateapp/
├── controllers/ # Application controllers
├── models/ # ActiveRecord models
├── views/ # Slim templates
├── uploaders/ # CarrierWave uploaders
├── assets/ # JavaScript, CSS, images
└── helpers/ # View helpers
spec/
├── models/ # Model specs
├── controllers/ # Controller specs
├── acceptance/ # Feature specs
└── factories/ # Factory Bot factories
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- File uploads are validated for type and size
- CSRF protection is enabled
- User authentication required for creating/modifying content
- SQL injection protection via ActiveRecord
This project is available as open source.