商务课程
class Business < ApplicationRecord
.........
belongs_to :user
has_many :likes
喜欢上课
class Like < ApplicationRecord
belongs_to :user
belongs_to :business
.....
用户类
class User < ApplicationRecord
has_many :likes
has_many :businesses
....
业务/show.html.erb
<%= button_tag "Like", data: {reflex: "click->Likes#like", id: @business.id} %>
class LikesReflex < ApplicationReflex
def like
business = Business.find(element.dataset[:id])
business.likes.find_or_create_by(user: current_user)
......
我需要帮助来设置 likeReflex 控制器。我希望登录用户喜欢业务并将它们添加到他们的 user.likes