Class: Api::V1::TicketsController
- Inherits:
-
BaseController
- Object
- BaseController
- Api::V1::TicketsController
- Defined in:
- app/controllers/api/v1/tickets_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/controllers/api/v1/tickets_controller.rb', line 27 def create @ticket = Ticket.new(params[:ticket]) if @ticket.save render :json => {:success => true} and return else render :json => {:success => false, :errors => @ticket.errors..to_sentence} and return end end |
#index ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/api/v1/tickets_controller.rb', line 2 def index @bucket = Ticket.order("name") @bucket = @bucket.where(:project_id => params[:project_id]) unless params[:project_id].blank? @bucket = @bucket.for_repo_url_and_branch(params[:repo_url],params[:branch]) unless params[:repo_url].blank? && params[:branch].blank? json_array = [] @bucket.all.each do |ticket| json_array << build_hash_for_ticket(ticket) end render :json => json_array end |
#show ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/api/v1/tickets_controller.rb', line 15 def show @ticket = Ticket.find params[:id] json_hash = { :name => @ticket.name, :estimated_hours => @ticket.estimated_hours, :percentage_complete => @ticket.percentage_complete, :hours => @ticket.hours } render :json => json_hash end |