Skip to content

Beihang University (BUAA) 2022 Ruby language programming course assignment. 北航 2022 Ruby 语言程序设计课程大作业

Notifications You must be signed in to change notification settings

github-bowen/BUAA-Rails-Blog-App

Repository files navigation

BUAA-Rails-Blog-App

中文版

Table of Contents

This is a travel blog sharing web application developed based on the Ruby on Rails framework. It is also the final project for the "Ruby Programming" course at Beihang University.

Requirements

System Requirements

  • Operating System: Windows 10 or Ubuntu 20.04

Software Versions

  • Ruby: 3.1.2
  • Rails: 7.0.4
  • sqlite3: 1.4
  • yarn: 1.22.19
  • nodejs: 16.17.1

For more dependencies, please refer to the Gemfile file in the project.

Installation and Setup

  1. Clone the project repository:
git clone https://github.com/github-bowen/BUAA-Rails-Blog-App.git
cd BUAA-Rails-Blog-App
  1. Install project dependencies:
bundle install
  1. Set up the database:
rails db:migrate
  1. (Optional) Initialize seed data:
rails db:init_data
  1. Build frontend assets:
yarn install  # If issues occur, try: yarn install --ignore-engines
yarn build:css

Note: The above initialization steps only need to be performed once.

Running the Project

Start the development server:

rails s

Then visit http://localhost:3000 in your browser to use the application.

Project Overview

Registration and Login

The homepage looks like this:

1

Click the "Register" button at the top right to create a new account:

1

After registering, you will be automatically logged in and redirected back to the page you were previously visiting:

1

Blog Browsing and Demonstration

Click on any blog to view its details:

1

1

1

After posting a comment:

1

You can delete comments after posting them.

Editing Personal Profile

1

User Permission Management

Since creating hotels, hotel rooms, airlines, and flight routes requires administrator privileges, a permission management page is provided for testing purposes.

1

You can promote a regular user to an administrator:

1

Viewing Registered Users (Admin Only)

1

As an administrator, you can delete user accounts.

Managing Hotels, Hotel Rooms, Airlines, and Flight Routes (Admin Only)

Manage these four data models:

  • When creating a hotel room type, you must first select the hotel it belongs to;
  • When creating a flight route, you must first select the associated airline;
  • In short: there is a one-to-many relationship between hotels and room types, and between airlines and flight routes.

1

1

The above shows the hotel room management page; other pages are similar.

Travel Route Management

Add a travel route:

1

1

After creation, you can view the details:

1

Travel routes also have a one-to-many relationship with hotels and flight routes.

Blog Operations

Create a new blog:

1

After creation:

1

1

Delete a blog:

1

Troubleshooting (Windows Specific Issues)

Issue: uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger

If you encounter the following error when running Rails commands on Windows:

C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support/logger_thread_safe_level.rb:12:in `<module:LoggerThreadSafeLevel>': uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

Solution

  1. Manually Load Logger Open config/boot.rb and add the following line at the top:

    require 'logger'
  2. Disable bootsnap Temporarily In the same file, comment out the following line:

    # require 'bootsnap/setup'
  3. Clear Cache Manually delete the tmp/cache/bootsnap folder to ensure no old cache files interfere.

  4. Reinstall Dependencies Run the following commands to reinstall dependencies:

    bundle install --force
  5. Restart Rails Server Restart the Rails server:

    rails s

About

Beihang University (BUAA) 2022 Ruby language programming course assignment. 北航 2022 Ruby 语言程序设计课程大作业

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published