-
-
Save DCarper/785035 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
@company = Company.find(params[:id]) | |
@ticket = Ticket.new(:app => @ticket) | |
respond_to do |format| | |
format.html # new.html.erb | |
format.xml { render :xml => @company } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- form_for @ticket do |f| | |
= f.error_messages | |
= f.hidden_field :ticketable_id | |
= f.hidden_field :ticketable_type | |
%p | |
= f.label :title, "Brief Title for Issue" | |
= f.text_field :title | |
%p | |
= f.label :call_type | |
%br/ | |
= f.select :call_type, Ticket::Types.collect { |t| [t.first.to_s, t.last] } | |
#ticket_priority_field.field | |
= f.label :priority | |
%br/ | |
= f.select :priority, Ticket.priorities.keys | |
%p | |
= f.label :description | |
%br/ | |
= f.text_area :description | |
%p | |
= f.label :call_back_needed | |
%br/ | |
= f.check_box :call_back_needed | |
%p | |
= f.label :status | |
%br/ | |
= f.select :status, Ticket::Status.collect { |t| [t.first.to_s, t.last] } | |
%p | |
Assigned to: | |
%br/ | |
= f.select("user_id", User.all.collect {|p| [ p.email.to_s, p.id ] }, { :include_blank => true }) | |
%p= f.submit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TicketsController < ApplicationController | |
# before_filter :find_person | |
# before_filter :find_company | |
# before_filter :find_user | |
# before_filter :find_ticket, :only => [:show, :edit, :update, :destroy] | |
def show | |
@ticket = Ticket.find(params[:id]) | |
# @comments = Comment.all | |
# @comment = @ticket.comments.build | |
end | |
def new | |
@ticket = Ticket.new | |
#@ticket = @person.tickets.build | |
end | |
def create | |
@ticket = Ticket.new(params[:ticket]) | |
@user = current_user | |
if @ticket.save | |
redirect_to @ticket, :notice => 'Ticket was created successfully' | |
else | |
flash[:notice] = 'Ticket was not created Successfully.' | |
render = 'new' | |
end | |
end | |
def edit | |
end | |
def update | |
if @ticket.update_attributes(params[:ticket]) | |
flash[:notice] = "Ticket has been updated." | |
redirect_to [@person, @ticket] | |
else | |
flash[:alert] = "Ticket has not been updated." | |
render :action => "edit" | |
end | |
end | |
def destroy | |
@ticket.destroy | |
flash[:notice] = "Ticket has been deleted." | |
redirect_to @person | |
end | |
private | |
def find_company | |
@company = Company.find(params[:company_id]) | |
end | |
def find_person | |
@person = Person.find(params[:person_id]) | |
end | |
def find_user | |
@user = User.find(params[:user_id]) | |
end | |
def find_ticket | |
@ticket = @person.tickets.find(params[:id]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment