Class: Homeland::Site::SitesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/homeland/site/sites_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/homeland/site/sites_controller.rb', line 12

def create
  authorize! :create, ::Site
  @site = ::Site.new(site_params)
  @site.user_id = current_user.id
  if @site.save
    redirect_to(sites_path, notice: '提交成功。谢谢。')
  else
    render action: 'new'
  end
end

#indexObject



3
4
5
# File 'app/controllers/homeland/site/sites_controller.rb', line 3

def index
  @site_nodes = SiteNode.all.order(sort: :desc)
end

#newObject



7
8
9
10
# File 'app/controllers/homeland/site/sites_controller.rb', line 7

def new
  authorize! :create, ::Site
  @site = ::Site.new
end