Class: Kuroko2::JobDefinitionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Kuroko2::JobDefinitionsController
- Defined in:
- app/controllers/kuroko2/job_definitions_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/kuroko2/job_definitions_controller.rb', line 39 def create @definition = Kuroko2::JobDefinition.new(definition_params) @definition.admins << current_user if @definition.save current_user.stars.create(job_definition: @definition) redirect_to @definition, notice: 'Job Definition was successfully created.' else render :new end end |
#destroy ⇒ Object
70 71 72 73 74 |
# File 'app/controllers/kuroko2/job_definitions_controller.rb', line 70 def destroy @definition.destroy redirect_to job_definitions_path, notice: 'Job Definition was successfully destroyed.' end |
#edit ⇒ Object
52 53 |
# File 'app/controllers/kuroko2/job_definitions_controller.rb', line 52 def edit end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/kuroko2/job_definitions_controller.rb', line 4 def index rel = Kuroko2::JobDefinition query = query_params[:q] if query.present? rel = rel.search_by(query) end @input_tags = query_params[:tag] || [] if @input_tags.present? rel = rel.tagged_by(@input_tags) end if query.present? || @input_tags.present? @related_tags = rel.includes(:tags).map(&:tags).flatten.uniq else @related_tags = Kuroko2::Tag.all end @definitions = rel.ordered.page(page_params[:page]) end |
#new ⇒ Object
35 36 37 |
# File 'app/controllers/kuroko2/job_definitions_controller.rb', line 35 def new @definition = Kuroko2::JobDefinition.new end |
#show ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/controllers/kuroko2/job_definitions_controller.rb', line 26 def show @instances = @definition.job_instances.page(0) @schedules = @definition.job_schedules @suspend_schedules = @definition.job_suspend_schedules @schedule = Kuroko2::JobSchedule.new(job_definition: @definitions) @suspend_schedule = Kuroko2::JobSuspendSchedule.new(job_definition: @definitions) end |
#update ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/kuroko2/job_definitions_controller.rb', line 55 def update success = ActiveRecord::Base.transaction do @definition.attributes = definition_params @definition.admins = Kuroko2::User.active.with(admin_id_params) @definition.save end if success redirect_to @definition, notice: 'Job Definition was successfully updated.' else render :edit end end |