Tag: 模型 视图 控制器源

如何使用私人提交活动Feed?

我们如何为用户提供将活动设为私有的选项? 这将为用户提供他们想要的post的隐私权。 有人告诉我这段代码不起作用,因为它可能与“没有设置’私人’复选框以正常工作”有关 ,但私有复选框适用于隐藏公共配置文件上的提交 (只是不在活动源上) )。 class ActivitiesController < ApplicationController def index #Added .public @activities = Activity.visible.order("created_at desc").where(user_id: current_user.following_ids) end end class Activity { where(:hidden => false) } def visible? !hidden end end create_table “activities”, force: true do |t| t.boolean “hidden”, default: false t.integer “user_id” t.string “action” t.integer “trackable_id” t.string “trackable_type” t.datetime “created_at”, null: false […]

如何提交Feed的多态注释?

如果用户单击[+注释]按钮 他面对这个邪恶的野兽: ActiveRecord::RecordNotFound in CommentsController#create Couldn’t find Comment with ‘id’= Line: @commentable = resource.singularize.classify.constantize.find(id) 活动/指数 评论/ _form Comment activities_controller def index @activities = Activity.order(“created_at desc”).where(user_id: current_user.following_ids) @commentable = @activity @comment = Comment.new end 错误可以在这里找到: class CommentsController < ApplicationController before_action :load_commentable before_action :set_comment, only: [:show, :edit, :update, :destroy, :like] before_action :logged_in_user, only: [:create, :destroy] def index […]