thirteen-tien-len/app/controllers/microposts_controller.rb
2023-11-15 12:30:47 +00:00

22 lines
418 B
Ruby

class MicropostsController < ApplicationController
def create
@micropost = current_user.microposts.build(micropost_params)
authorize @micropost
if @micropost.save
flash[:success] = "Micropost created!"
redirect_to root_url
else
render 'users/show'
end
end
def destroy
end
private
def micropost_params
params.require(:micropost).permit(:content)
end
end