This repository has some features that twitter has as it's named. :-) It also has the admin page (http://localhost:3000/admin), but it consists of sample code that intends to show how to write basic features such as search, csv import/export and so on. So the page is nothing to do with twitter.
Haven't payed much attention to the design/style for now.
- This repository has some
NOTEhere and there. But they are for education purposes. You shouldn't mimic them when you write code for production. ridgepoleis used instead of the Rails default db migration.ridgepoleis especially useful where many developers are working on the same repository and many services are referring to the same database.
- Ruby 3.2.9
- Ruby on Rails 8.0.2
- Postgresql 9.3 or later
The following software should be installed (by brew on Mac)
- yarn
- Docker (for PostgreSQL)
-
Install packages
bundle install --path vendor/bundle
yarn install
-
Database setup
# Start PostgreSQL using Docker docker compose up -d # Wait for PostgreSQL to be ready sleep 30 # Create and migrate the database bundle exec rails db:create bundle exec rails ridgepole:apply
# You should run the commands above intead of bin/rails db:setup as ridgepole is used. # You should pass RAILS_ENV, like RAILS_ENV=production, for an environment besides development as follows. $ bundle exec rails ridgepole:apply RAILS_ENV=production
-
Setup environment variables if needed (Maybe not. Skip the step if the yml file doesn't exist.)
config/settings.yml
-
Start local servers
$ bundle exec foreman start => You should access http://localhost:5000/ or (Execute the following commands on different tabs) $ bin/rails server $ bin/webpack-dev-server
-
You have to sign up first from http://localhost:3000/signup to login.
-
If you want to create test data, see below.
bundle exec rspec$ bin/rails dev:generate_data
# You can specify arguments
$ bin/rails 'dev:generate_data[100,10,20]'
-> A test user is created with the following email and password (test@example.com / password).Lefthook is used for git hooks to ensure code quality. Since it's included in the Gemfile, it will be available when you run bundle install.
In most cases, the git hooks are automatically installed. However, if you need to reinstall or update them (such as after cloning the repository or if the hooks become corrupted), you can run:
bundle exec lefthook installLefthook will automatically run checks before each commit to ensure code quality.
In case you have to ignore hooks
SKIP=HOOK COMMAND
e.g. SKIP=rubocop git commit ...
e.g. LEFTHOOK=0 git commit ...Until this merge is released, RuboCop raises 'Extra line detected'. Fix manually.
lograge is used. So the following command should be used instead of Rails.logger.
LogrageLogger.call({ message: 'error message comes here' }, error: e)For details about the Ruby and Rails upgrade process, see UPGRADE_SUMMARY.md.