1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

fix update setting from client

This commit is contained in:
Sylvain 2018-12-27 14:15:58 +01:00
parent a23e514935
commit 10e3d4c3e4
2 changed files with 22 additions and 14 deletions

View File

@ -4,7 +4,10 @@ Application.Services.factory('Setting', ['$resource', function ($resource) {
return $resource('/api/settings/:name', return $resource('/api/settings/:name',
{ name: '@name' }, { { name: '@name' }, {
update: { update: {
method: 'PUT' method: 'PUT',
transformRequest: (data) => {
return angular.toJson({ setting: data });
}
}, },
query: { query: {
isArray: false isArray: false

View File

@ -1,6 +1,6 @@
class API::ProjectsController < API::ApiController class API::ProjectsController < API::ApiController
before_action :authenticate_user!, except: [:index, :show, :last_published, :search] before_action :authenticate_user!, except: %i[index show last_published search]
before_action :set_project, only: [:update, :destroy] before_action :set_project, only: %i[update destroy]
respond_to :json respond_to :json
def index def index
@ -13,7 +13,7 @@ class API::ProjectsController < API::ApiController
end end
def show def show
@project = Project.friendly.find(params[:id]) @project = Project.friendly.find(params[:id])
end end
def create def create
@ -62,15 +62,20 @@ class API::ProjectsController < API::ApiController
end end
private private
def set_project
@project = Project.find(params[:id])
end
def project_params def set_project
params.require(:project).permit(:name, :description, :tags, :machine_ids, :component_ids, :theme_ids, :licence_id, :author_id, :licence_id, :state, @project = Project.find(params[:id])
user_ids: [], machine_ids: [], component_ids: [], theme_ids: [], project_image_attributes: [:attachment], end
project_caos_attributes: [:id, :attachment, :_destroy],
project_steps_attributes: [:id, :description, :title, :_destroy, :step_nb, def project_params
:project_step_images_attributes => [:id, :attachment, :_destroy]]) params.require(:project).permit(:name, :description, :tags, :machine_ids, :component_ids, :theme_ids, :licence_id,
end :author_id, :licence_id, :state,
user_ids: [], machine_ids: [], component_ids: [], theme_ids: [],
project_image_attributes: [:attachment],
project_caos_attributes: %i[id attachment _destroy],
project_steps_attributes: [
:id, :description, :title, :_destroy, :step_nb,
project_step_images_attributes: %i[id attachment _destroy]
])
end
end end