mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 20:00:49 +08:00
init project
This commit is contained in:
36
app/controllers/admins/repertoires_controller.rb
Normal file
36
app/controllers/admins/repertoires_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class Admins::RepertoiresController < Admins::BaseController
|
||||
|
||||
def index
|
||||
@repertoires = Repertoire.all
|
||||
end
|
||||
|
||||
def edit
|
||||
@repertoire = current_repertoire
|
||||
end
|
||||
|
||||
def update
|
||||
Rails.logger.info("#################--------")
|
||||
if params[:repertoire] && params[:repertoire][:name].present?
|
||||
name = params[:repertoire][:name].to_s.strip
|
||||
current_repertoire.update_attributes!(name: name)
|
||||
end
|
||||
@repertoires = Repertoire.all
|
||||
end
|
||||
|
||||
def create
|
||||
name = params[:name].to_s.strip
|
||||
return render_error('名称重复') if Repertoire.where(name: name).exists?
|
||||
Repertoire.create!(name: name)
|
||||
render_ok
|
||||
end
|
||||
|
||||
def destroy
|
||||
@repertoire_id = params[:id]
|
||||
current_repertoire.destroy!
|
||||
end
|
||||
|
||||
private
|
||||
def current_repertoire
|
||||
@_current_repertoire = Repertoire.find params[:id]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user