这里是ruby rails + grape + sidekiq的一段实践过程,新手过程,只作为一段记录;
1、ruby + rails
(1)搭建ruby rails 环境
(2)新建项目文件夹
rails news grape_test

此时在/usr/local/demo/目录下出现创建了项目文件夹grap_test;
(3)替换sqlite3为mysql
本地安装好mysql之后,再用gem安装mysql2适配器:
gem install mysql2
在gemfile文件中替换掉sqlite3:
# gem 'sqlite3'
gem 'mysql2'
# 替换掉sqlite3
然后修改config/database.yml中的参数:
# config/database.yml
#
default: &default
adapter: mysql2
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
username: root
password: 'ur password'
development:
<<: *default
database: twi
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: twi_test
production:
<<: *default
database: twi_pro
安装和配置好之后运行rails s会报没有找到数据库的错误,所以需要将数据库创建和迁移:

这篇博客记录了一位新手使用Ruby on Rails、Grape和Sidekiq进行项目实践的过程。首先介绍了如何搭建Ruby Rails环境,从创建项目到将数据库从sqlite3替换为mysql。接着,详细讲解了安装和配置Grape来创建API。最后,讨论了如何集成Sidekiq进行异步任务处理,包括安装Redis、配置Sidekiq以及测试异步任务的执行。

472

被折叠的 条评论
为什么被折叠?



