class MainController < ApplicationController include MainHelper before_action :logged_in_user def show @user = current_user offset = 0 @micro_posts_array = read_newest_post(offset) render 'main' end def activity micro_post_id = params[:micropost_id] join = params[:join].to_s micro_post = MicroPost.find_by(id: micro_post_id) if join == "true" micro_post.engage_people += 1 else micro_post.engage_people -= 1 end if micro_post.save render json: {total_num: micro_post.engage_people} end end end