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



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

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



5
6
7
# File 'app/controllers/homeland/site/sites_controller.rb', line 5

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

#newObject



9
10
11
12
# File 'app/controllers/homeland/site/sites_controller.rb', line 9

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