app/controllers/wiki/pages_controller.rb in tawork-0.0.11 vs app/controllers/wiki/pages_controller.rb in tawork-0.0.12

- old
+ new

@@ -90,9 +90,22 @@ def subpages_dropdown render partial: 'subpages_dropdown' end + def star + starred = Starred.where(user_id: current_user.id, starrable_id: @page, starrable_type: @page.class).first + + if starred && params[:to_star] == "false" + starred.destroy + end + + if !starred && params[:to_star] == "true" + Starred.create(user: current_user, starrable: @page) + end + render json: {} + end + protected def load_page @page = Page.find(params[:id]) if params[:id] end