public-activity

Limit user to 1 like?

*爱你&永不变心* 提交于 2020-01-25 11:19:52
问题 How can we limit a user to 1 like per comment? comments_controller.rb def like @comment = Comment.find(params[:id]) @comment.increment!(:likes) @comment.create_activity :like flash[:success] = 'Thanks for liking!' redirect_to(:back) end _comments.html.erb <% @comments.each do |comment| %> <%= User.find(comment.user_id).name %> <%= simple_format comment.content %> <%= pluralize(comment.likes, 'like') %> <%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-thumbs-up') + ' Like it',

Limit user to 1 like?

送分小仙女□ 提交于 2020-01-25 11:19:11
问题 How can we limit a user to 1 like per comment? comments_controller.rb def like @comment = Comment.find(params[:id]) @comment.increment!(:likes) @comment.create_activity :like flash[:success] = 'Thanks for liking!' redirect_to(:back) end _comments.html.erb <% @comments.each do |comment| %> <%= User.find(comment.user_id).name %> <%= simple_format comment.content %> <%= pluralize(comment.likes, 'like') %> <%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-thumbs-up') + ' Like it',

How to use parameters value from public_activity gem (Rails)?

╄→гoц情女王★ 提交于 2019-12-22 10:56:27
问题 I am building a Rails app. And in my app, there are Projects where users can "Follow". When a user follows one of the pages, he/she will get updates if somebody uploads/creates a folder/file. Below is the screenshot when somebody just created a new folder: And below is the code for "Create" action in my Folder controller: def create @folder = current_user.folders.where(project_id: params[:project_id]).create(folder_params) respond_to do |format| if @folder.save @folder.create_activity :create

How to use private submit to hide from feed?

与世无争的帅哥 提交于 2019-12-07 00:12:45
问题 In the valuations form there is a submit button and a <%= f.submit :private %> button. If private submit is clicked the submitted info will be hidden to other user's who view the profile. How can we also use <%= f.submit :private %> to hide submitted info from showing on the feed? activities/index.html.erb <h1>Feed</h1> <% @activities.each do |activity| %> <% if current_user == @user %> <%= render_activity activity %> <% else %> <%= render_activity activity %> #We'd need to make .public