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
27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 27 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
45 46 47 48 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 45 def destroy @site.destroy redirect_to(admin_sites_path, notice: "#{@site.name} 删除成功。") end |
#edit ⇒ Object
24 25 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 24 def edit end |
#index ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 9 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
20 21 22 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 20 def new @site = ::Site.new end |
#show ⇒ Object
17 18 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 17 def show end |
#undestroy ⇒ Object
50 51 52 53 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 50 def undestroy @site.update_attribute(:deleted_at, nil) redirect_to(admin_sites_path, notice: "#{@site.name} 已恢复。") end |
#update ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/controllers/homeland/site/admin/sites_controller.rb', line 37 def update if @site.update(params[:site].permit!) redirect_to(admin_sites_path, notice: "Site 更新成功。") else render action: "edit" end end |