22 lines
418 B
Ruby
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
|