- BUAA-Rails-Blog-App
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.
- Operating System: Windows 10 or Ubuntu 20.04
- 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.
- Clone the project repository:
git clone https://github.com/github-bowen/BUAA-Rails-Blog-App.git
cd BUAA-Rails-Blog-App
- Install project dependencies:
bundle install
- Set up the database:
rails db:migrate
- (Optional) Initialize seed data:
rails db:init_data
- 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.
Start the development server:
rails s
Then visit http://localhost:3000 in your browser to use the application.
The homepage looks like this:
Click the "Register" button at the top right to create a new account:
After registering, you will be automatically logged in and redirected back to the page you were previously visiting:
Click on any blog to view its details:
After posting a comment:
You can delete comments after posting them.
Since creating hotels, hotel rooms, airlines, and flight routes requires administrator privileges, a permission management page is provided for testing purposes.
You can promote a regular user to an administrator:
As an administrator, you can delete user accounts.
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.
The above shows the hotel room management page; other pages are similar.
Add a travel route:
After creation, you can view the details:
Travel routes also have a one-to-many relationship with hotels and flight routes.
Create a new blog:
After creation:
Delete a blog:
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)
-
Manually Load
Logger
Openconfig/boot.rb
and add the following line at the top:require 'logger'
-
Disable
bootsnap
Temporarily In the same file, comment out the following line:# require 'bootsnap/setup'
-
Clear Cache Manually delete the
tmp/cache/bootsnap
folder to ensure no old cache files interfere. -
Reinstall Dependencies Run the following commands to reinstall dependencies:
bundle install --force
-
Restart Rails Server Restart the Rails server:
rails s