Method: IshManager::MapsController#create

Defined in:
app/controllers/ish_manager/maps_controller.rb

#createObject

alphabetized

[View source]

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/ish_manager/maps_controller.rb', line 9

def create
  @map = ::Gameui::Map.new(map_params)

  if params[:image]
    image = ::Ish::ImageAsset.new :image => params[:image]
    @map.image = image
    image.save
  end

  if map_params[:parent_slug].present?
    @map.parent = ::Gameui::Map.find_by({ slug: map_params[:parent_slug] })
  end
  authorize! :create, @map

  if @map.save
    redirect_to map_path(@map), notice: 'Map was successfully created.'
  else
    render :new
  end
end