Skip to content
Permalink
Browse files

fixed delete

  • Loading branch information
rcb09003 committed Nov 18, 2013
1 parent 1216c30 commit c9fa5d82c592f70a6c7e97d604d5ad8815477ddc
Showing with 33 additions and 1 deletion.
  1. +2 −1 app/controllers/microposts_controller.rb
  2. +30 −0 app/controllers/tickets_controller.rb
  3. +1 −0 app/models/micropost.rb
@@ -1,5 +1,6 @@
class MicropostsController < ApplicationController
before_action :signed_in_user
before_action :signed_in_user, only: [:create, :destroy]
before_action :correct_user, only: :destroy

def create
@micropost = current_user.microposts.build(micropost_params)
@@ -0,0 +1,30 @@
class TicketsController < ApplicationController
before_action :signed_in_user

def create
@ticket = current_user.ticket.build(ticket_params)
if @ticket.save
flash[:success] = "Ticket Posted!"
redirect_to root_url
else
@feed_items = []
render 'static_pages/home'
end
end

def destroy
@ticket.destroy
redirect_to root_url
end

private

def ticket_params
params.require(:ticket).permit()
end
def correct_user
@ticket = current_user.tickets.find_by(id: params[:id])
redirect_to root_url if @ticket.nil?
end

end
@@ -1,4 +1,5 @@
class Micropost < ActiveRecord::Base
before_save { }
belongs_to :user
default_scope -> { order('created_at DESC') }
validates :content, presence: true, length: { maximum: 140 }

0 comments on commit c9fa5d8

Please sign in to comment.
You can’t perform that action at this time.