ensl.org/app/controllers/shoutmsgs_controller.rb

33 lines
697 B
Ruby
Raw Normal View History

class ShoutmsgsController < ApplicationController
respond_to :html, :js
2020-03-08 22:07:12 +00:00
def index
@shoutmsgs = Shoutmsg.typebox
2020-03-08 22:07:12 +00:00
end
def show
if params[:id2]
@shoutmsgs = Shoutmsg.recent.of_object(params[:id], params[:id2]).reverse
else
@shoutmsgs = Shoutmsg.recent.box
end
end
def create
@shoutmsg = Shoutmsg.new params[:shoutmsg]
@shoutmsg.user = cuser
raise AccessError unless @shoutmsg.can_create? cuser
unless @shoutmsg.save
flash[:error] = t(:invalid_message)
end
end
def destroy
@shoutmsg = Shoutmsg.find params[:id]
raise AccessError unless @shoutmsg.can_destroy? cuser
@shoutmsg.destroy
redirect_to_back
end
end