Class: Houston::Roadmaps::RoadmapMilestonesController

Inherits:
RoadmapsController
  • Object
show all
Defined in:
app/controllers/houston/roadmaps/roadmap_milestones_controller.rb

Instance Method Summary collapse

Methods inherited from RoadmapsController

#create, #edit, #history, #new, #show

Instance Method Details

#indexObject



8
9
10
11
# File 'app/controllers/houston/roadmaps/roadmap_milestones_controller.rb', line 8

def index
  authorize! :read, Roadmap
  render json: Houston::Roadmaps::RoadmapMilestonePresenter.new(@roadmap.milestones)
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/houston/roadmaps/roadmap_milestones_controller.rb', line 14

def update
  authorize! :update, @roadmap

  @roadmap.commits.create!(
    user: current_user,
    message: params[:message],
    milestone_changes: params.fetch(:roadmap, {}).values)

  head :ok
rescue ActiveRecord::RecordInvalid
  render json: $!.record.errors, status: 422
end