2018-05-01 07:59:20 +02:00
|
|
|
class GlossaryTermsController < ApplicationController
|
|
|
|
|
2018-05-04 02:40:20 +02:00
|
|
|
before_action :find_term_from_id, only: [:show]
|
|
|
|
|
2018-05-01 07:59:20 +02:00
|
|
|
def index
|
2018-05-01 17:42:01 +02:00
|
|
|
@glossary_terms = GlossaryTerm.all
|
2018-05-01 07:59:20 +02:00
|
|
|
end
|
2018-05-04 02:40:20 +02:00
|
|
|
|
2018-05-05 04:15:27 +02:00
|
|
|
def new
|
|
|
|
@term = GlossaryTerm.new
|
|
|
|
end
|
2018-05-04 02:40:20 +02:00
|
|
|
|
2018-05-05 09:53:58 +02:00
|
|
|
def create
|
|
|
|
term = GlossaryTerm.new(glossary_term_params)
|
|
|
|
if term.save
|
|
|
|
flash[:notice] = l(:notice_successful_create)
|
|
|
|
redirect_to glossary_term_path(term.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-04 02:40:20 +02:00
|
|
|
# Find the term whose id is the :id parameter
|
|
|
|
def find_term_from_id
|
|
|
|
@term = GlossaryTerm.find(params[:id])
|
2018-05-04 03:08:14 +02:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render_404
|
2018-05-04 02:40:20 +02:00
|
|
|
end
|
2018-05-05 09:53:58 +02:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def glossary_term_params
|
|
|
|
params.require(:glossary_term).permit(
|
|
|
|
:name, :description
|
|
|
|
)
|
|
|
|
end
|
2018-05-01 07:59:20 +02:00
|
|
|
end
|