Skip to content
Snippets Groups Projects
Commit fe9a1e31 authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Update variables from within it's own controller not the project's

parent ee7e4fd3
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -15,6 +15,7 @@ v7.14.0 (unreleased)
- Add missing stage when doing retry
- Require variable keys to be not-empty and unique
- Fix variable saving issue
- Display variable saving errors in variables page not the project's
v7.13.1
- Fix: user could steal specific runner
Loading
Loading
Loading
Loading
@@ -6,7 +6,17 @@ class VariablesController < ApplicationController
 
layout 'project'
 
def index
def show
end
def update
if project.update_attributes(project_params)
EventService.new.change_project_settings(current_user, project)
redirect_to :back, notice: 'Variables was successfully updated.'
else
render action: 'show'
end
end
 
private
Loading
Loading
@@ -14,4 +24,8 @@ class VariablesController < ApplicationController
def project
@project ||= Project.find(params[:project_id])
end
def project_params
params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] })
end
end
Loading
Loading
@@ -7,7 +7,7 @@
%hr
 
 
= nested_form_for @project, html: { class: 'form-horizontal' } do |f|
= nested_form_for @project, url: url_for(controller: 'variables', action: 'update'), html: { class: 'form-horizontal' } do |f|
- if @project.errors.any?
#error_explanation
%p.lead= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:"
Loading
Loading
Loading
Loading
@@ -66,7 +66,7 @@ Rails.application.routes.draw do
resources :runner_projects, only: [:create, :destroy]
 
resources :events, only: [:index]
resources :variables, only: [:index]
resource :variables, only: [:show, :update]
end
 
resource :user_sessions do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment