fix: verify software_id before save change of a gitub repository

This commit is contained in:
Adrien Waksberg 2018-07-30 22:15:05 +02:00
parent 5d948b79bd
commit 4e62cb6593

View file

@ -1,16 +1,20 @@
class GithubRepositoryController < ApplicationController class GithubRepositoryController < ApplicationController
def create def create
if params[:repository][:software_id] == params[:software_id]
@software = Software.find(params[:software_id]) @software = Software.find(params[:software_id])
@repository = GithubRepository.new(repository_params) @repository = GithubRepository.new(repository_params)
@repository.save @repository.save
end
redirect_to edit_software_path(@software) redirect_to edit_software_path(@software)
end end
def update def update
if params[:repository][:software_id] == params[:software_id]
@software = Software.find(params[:software_id]) @software = Software.find(params[:software_id])
@repository = GithubRepository.find(params[:id]) @repository = GithubRepository.find(params[:id])
@repository.update(repository_params) @repository.update(repository_params)
end
redirect_to edit_software_path(@software) redirect_to edit_software_path(@software)
end end