I am trying to give privacy settings to my users, I created a
privacy_settings table and model with the following fields:
where setting has three options: public, private and friends and the
user can select an option.
if the user selects, say for example private, then any other user cannot
view his profile.
Another expert helped me with the below methods to accomplish this,
still inspite of the perfectly seeming logic, the validation is not
working and the access is being given to users irrespective of what the
privacy settings of the user are…
before_filter :verify_privacy, :only => :show
private def verify_privacy @user = User.find(params[:id], :include => :privacy_setting) return true if @user.privacy_setting.setting = "public" return false if @user.privacy_setting.setting = "private" if @user.privacy_setting.setting = "friends" and
has_many :friends, :through => :friendships #or however you solved
Could anyone please guide me on this issue…