Sha256: 5bb74c46f7487e2837fb16069ac2471698dd0fc21e7c8f84a23ea6431d11468d
Contents?: true
Size: 723 Bytes
Versions: 20
Compression:
Stored size: 723 Bytes
Contents
class MicropostsController < ApplicationController before_action :signed_in_user, only: [:create, :destroy] before_action :correct_user, only: :destroy def create @micropost = current_user.microposts.build(micropost_params) if @micropost.save flash[:success] = "Micropost created!" redirect_to root_url else @feed_items = [] render 'static_pages/home' end end def destroy @micropost.destroy redirect_to root_url end private def micropost_params params.require(:micropost).permit(:content) end def correct_user @micropost = current_user.microposts.find_by(id: params[:id]) redirect_to root_url if @micropost.nil? end end
Version data entries
20 entries across 20 versions & 2 rubygems