Class: Homeland::Site::Admin::SitesController
- Inherits:
-
Admin::ApplicationController
- Object
- Admin::ApplicationController
- Homeland::Site::Admin::SitesController
- Defined in:
- app/controllers/homeland/site/admin/sites_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #undestroy ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 25 def create @site = ::Site.new(params[:site].permit!) if @site.save redirect_to(admin_sites_path, notice: 'Site 创建成功。') else render action: 'new' end end |
#destroy ⇒ Object
43 44 45 46 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 43 def destroy @site.destroy redirect_to(admin_sites_path, notice: "#{@site.name} 删除成功。") end |
#edit ⇒ Object
22 23 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 22 def edit end |
#index ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 7 def index @sites = ::Site.unscoped.recent.includes(:user, :site_node) if params[:q].present? @sites = @sites.where('name LIKE ?', "%#{params[:q]}%") end @sites = @sites.page(params[:page]) end |
#new ⇒ Object
18 19 20 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 18 def new @site = ::Site.new end |
#show ⇒ Object
15 16 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 15 def show end |
#undestroy ⇒ Object
48 49 50 51 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 48 def undestroy @site.update_attribute(:deleted_at, nil) redirect_to(admin_sites_path, notice: "#{@site.name} 已恢复。") end |
#update ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 35 def update if @site.update(params[:site].permit!) redirect_to(admin_sites_path, notice: 'Site 更新成功。') else render action: 'edit' end end |