How can we give the user the option to make activities private? This would give users privacy for posts they want for their eyes only.
I was told this code isn't working because it might have something to do with "not setting up the 'private' checkbox to work correctly", yet the private checkbox works for hiding submissions on the public profiles (just not on the activities feed).
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 < ActiveRecord::Base
belongs_to :user
has_many :comments, as: :commentable
belongs_to :trackable, polymorphic: true
scope :visible, ->{ 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
t.datetime "updated_at", null: false
end
And in one of the _forms, such as @valuations
or @goals
, is where the user can make the distinction via his submission:
<%= button_tag(type: 'submit', class: "btn", id: "gold") do %>
<span class="glyphicon glyphicon-plus"></span> Public
<% end %>
<%= button_tag(type: 'submit', class: "btn") do %>
<% :hidden %><span class="glyphicon glyphicon-plus"></span> Private
<% end %>
Thank you!