Giter VIP home page Giter VIP logo

Comments (4)

huacnlee avatar huacnlee commented on June 15, 2024

这个东西的设计是针对这类场景,上去就能用,我不在乎其他不用这类库的项目是否能用(其实是能用的 Devise 不是需要的,Gem 也没有依赖 Devise,而是设计了类似的接口,Bootstrap 也不是必要的,你看到的那是测试代码里面有),解决的目的是针对这一套

在 rails-engine 这个组里面所有的 Gem 实现思路都是这样的

from notifications.

lufeihaidao avatar lufeihaidao commented on June 15, 2024

还有个小问题,

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.

huacnlee avatar huacnlee commented on June 15, 2024

actor = user 的时候排除掉就好了

from notifications.

huacnlee avatar huacnlee commented on June 15, 2024

实际上 will_paginate 这种方式完全可以 Kaminari 共存的。

我已经测试过。

from notifications.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.