Finished Source controller
This commit is contained in:
parent
c96cea5ca6
commit
35f8ec4b2c
@ -9,8 +9,39 @@ class SourcesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@source = @project.sources.new(source_params)
|
||||||
|
if @source.save
|
||||||
|
flash[:notice] = 'Created new source'
|
||||||
|
redirect_to project_sources_url(@project)
|
||||||
|
else
|
||||||
|
@sources = @project.sources
|
||||||
|
render :index
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
# FIXME: do not destroy if anything depends on it
|
||||||
|
if @source.destroy
|
||||||
|
flash[:notice] = 'Deleted source'
|
||||||
|
end
|
||||||
|
redirect_to project_sources_url(@project)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def source_params
|
||||||
|
params.require(:source).permit(
|
||||||
|
:name,
|
||||||
|
:description
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# :find_* methods are called before :authorize,
|
||||||
|
# @project is required for :authorize to succeed
|
||||||
|
def find_source
|
||||||
|
@unit = Source.find(params[:id])
|
||||||
|
@project = @source.project
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -20,6 +20,7 @@ class UnitsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
# FIXME: do not destroy if anything depends on it
|
||||||
if @unit.destroy
|
if @unit.destroy
|
||||||
flash[:notice] = 'Deleted unit'
|
flash[:notice] = 'Deleted unit'
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user