A modern, full-featured Ruby on Rails web application for creating and managing blog content. Built with Rails conventions, security best practices, and a focus on maintainability.
git clone https://github.com/your-username/blogpage.git
cd blogpage
bundle install
yarn install
# Copy environment template
cp .env.example .env
Update .env with your configuration:
# Database
DATABASE_URL=postgresql://username:password@localhost/blogpage_development
# Rails
RAILS_ENV=development
SECRET_KEY_BASE=your_secret_key_base_here
# Email (for Devise)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-password
# File Storage (for production)
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_REGION=us-east-1
AWS_BUCKET=your-s3-bucket-name
# Create and migrate database
rails db:create
rails db:migrate
# Seed with sample data (optional)
rails db:seed
rails assets:precompile
# Development mode
rails server or bin/rails server
# Or with specific port
rails server -p 3000
http://localhost:3000http://localhost:3000/admin# Authentication & Authorization
gem 'devise' # User authentication
gem 'cancancan' # Authorization framework
gem 'rolify' # Role management
# Content & UI
gem 'image_processing' # Image variants with Active Storage
gem 'bootsnap' # Boot-time performance
gem 'sassc-rails' # Sass compilation
gem 'kaminari' # Pagination
# Admin & Search
gem 'activeadmin' # Admin interface
gem 'ransack' # Search functionality
# Development & Testing
gem 'rspec-rails' # BDD testing framework
gem 'factory_bot_rails' # Test data generation
gem 'capybara' # Integration testing
For testing and demonstration purposes, use these pre-seeded accounts:
| Role | Password | Abilities | |
|---|---|---|---|
| Super Admin | admin (username) | password123 | Full system access, user management |
| User | user@gmail.com | user123 | Read posts, comment, profile |
rails server or bin/rails server # Start development server
rails console # Interactive Rails console
rails generate # Generate Rails components
rails db:migrate # Run pending migrations
rails db:rollback # Rollback last migration
rails routes # Show all application routes
rails assets:precompile # Compile assets for production
# Run all tests
bundle exec rspec
# Run specific test files
bundle exec rspec spec/models/
bundle exec rspec spec/controllers/
# Run with coverage
COVERAGE=true bundle exec rspec
# Feature tests with Capybara
bundle exec rspec spec/features/
# Ruby linting
bundle exec rubocop
# Security scanning
bundle exec brakeman
# Dependency vulnerability check
bundle exec bundle-audit
RAILS_ENV=production# Dockerfile included for containerized deployment
docker build -t blogpage .
docker run -p 3000:3000 blogpage
# spec/models/post_spec.rb
RSpec.describe Post, type: :model do
it { should belong_to(:user) }
it { should validate_presence_of(:title) }
it { should validate_presence_of(:content) }
end
# spec/controllers/posts_controller_spec.rb
RSpec.describe PostsController, type: :controller do
describe "GET #index" do
it "returns a success response" do
get :index
expect(response).to be_successful
end
end
end
# spec/features/user_creates_post_spec.rb
RSpec.feature "User creates post", type: :feature do
scenario "successfully creates a new post" do
visit new_post_path
fill_in "Title", with: "My New Post"
click_button "Create Post"
expect(page).to have_content("Post was successfully created")
end
end
Built with 💎 Ruby on Rails