刚刚上线了新的通知系统,采用独立的 gem 提供的功能,以便简化内部的实现。 同时目的也可以正好验证通知功能 Rails Engine。
Ruby China 之前的通知表已经有接近 100 万条数据了,太多老数据我就没迁移了,只保留了 2016-01-01 之后的通知。
新的实现,可以参考这个 PR: https://github.com/ruby-china/ruby-china/pull/594
如果你也想在你的项目里面实现类似的功能,可以用:
https://github.com/rails-engine/notifications
从此以后,大家再也不用考虑应用里面的通知中心怎么实现了,用这个就可以了。
不过不知道为什么在我的 shell 里运行这句代码时:
rails g notifications:install
会出现这个:
Adding Homeland initializer (config/initializers/notifications.rb)...
create config/initializers/notifications.rb
Adding model (notification.rb)...
create app/models/notification.rb
Error: Command 'notifications:install:migrations' not recognized
Did you mean: `$ rake notifications:install:migrations` ?
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"
In addition to those, there are:
destroy Undo code generated with "generate" (short-cut alias: "d")
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.