Comments (4)
这个东西的设计是针对这类场景,上去就能用,我不在乎其他不用这类库的项目是否能用(其实是能用的 Devise 不是需要的,Gem 也没有依赖 Devise,而是设计了类似的接口,Bootstrap 也不是必要的,你看到的那是测试代码里面有),解决的目的是针对这一套
在 rails-engine 这个组里面所有的 Gem 实现思路都是这样的
from notifications.
还有个小问题,
class Comment
belongs_to :post
belongs_user :user
after_commit :create_notifications, on: [:create]
def create_notifications
Notification.create(
notify_type: 'comment',
actor: self.user,
user: self.post.user,
target: self)
end
end
这段代码中,如果 current_user == self.post.user,意味着我在我的帖子里回复,也会给自己发通知,但是在 ruby-china 上似乎并没有发生这种情况。是如何实现的呢?我搜了些答案,都表示不建议在 model 中获取 current_user
from notifications.
actor = user 的时候排除掉就好了
from notifications.
实际上 will_paginate 这种方式完全可以 Kaminari 共存的。
我已经测试过。
from notifications.
Related Issues (20)
- Example App?
- Nav Partial is not working in Notifications Controller HOT 2
- Rails 4.2.8 probelm with optional: true HOT 2
- searching the partial in the gems? HOT 8
- 应该移除 gem 对 will_paginate 的依赖。 HOT 1
- Little typo? HOT 1
- Add support Rails 6, please. HOT 1
- Unable to create notifications for user's followers HOT 2
- How do I create a notification partial for this view? HOT 1
- How to create notifications for this custom following relationships.
- How do I create notifications for comment replies?
- How do I exclude notification.actor from recieveing notifications? HOT 1
- Deployment on heroku: alias_method 'current_user' undefined HOT 1
- Dependency of Will Paginate vs kaminari
- Does this support rails 7? HOT 1
- DEFAULT_AVATAR 放到config中 HOT 1
- can i using for mongoid HOT 2
- Rails 5 compatibility HOT 1
- Directly inheriting from ActiveRecord::Migration is not supported within Rails 5.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notifications.