プロジェクト

全般

プロフィール

« | » 

リビジョン 8af218b4

高徹 高橋 徹 さんが7年以上前に追加

Make strong parameter instead of attr_accessible

差分を表示:

app/controllers/glossary_controller.rb
end
end
# This action is invoked by HTTP verb get and post.
#
def new
@term_categories = TermCategory.where(:project_id => @project.id).order(:position)
@term = Term.new(params[:term])
@term = Term.new(term_params)
@term.name = CGI::unescapeHTML(params[:new_term_name]) if params[:new_term_name]
@term.project_id = @project.id
......
@term_categories = TermCategory.where(:project_id => @project.id).order(:position)
if request.post? || request.put? || request.patch?
@term.attributes = params[:term]
@term.attributes = term_params
@term.updater_id = User.current.id
if @term.save
attach_files(@term, params[:attachments])
......
end
def add_term_category
@category = TermCategory.new(params[:category])
@category = TermCategory.new(term_category_params)
@category.project_id = @project.id
if request.post? and @category.save
respond_to do |format|
......
Attachment.attach_files(val, prm)
end
def term_params
params.require(:term).permit(
:project_id, :category_id, :author, :name, :name_en, :datatype, :codename, :description,
:rubi, :abbr_whole
) if params[:term]
end
def term_category_params
params.require(:category).permit(:name, :project_id, :position) if params[:category]
end
end

他の形式にエクスポート: Unified diff