Class: Admin::SheetResourceController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/admin/sheet_resource_controller.rb

Direct Known Subclasses

ScriptsController, StylesController

Instance Method Summary collapse

Instance Method Details

#createObject



28
29
30
31
32
# File 'app/controllers/admin/sheet_resource_controller.rb', line 28

def create
  model.parent_id = @root.id
  model.update_attributes!(params[model_symbol])
  response_for :create
end

#newObject



23
24
25
26
# File 'app/controllers/admin/sheet_resource_controller.rb', line 23

def new
  self.model = model_class.new_with_defaults
  response_for :new
end

#uploadObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/admin/sheet_resource_controller.rb', line 8

def upload
  if params[:upload].blank?  # necessary params are missing
    render :text => '', :status => :bad_request
  else
    @sheet = model_class.create_or_update_from_upload!(params[:upload][:upload])
    if @sheet.new_record?
      response_for :create
    else
      slug = params[:upload][:upload].original_filename.to_slug().gsub(/-dot-css$/,'.css').gsub(/-js/,'.js')
      flash[:notice] = "#{slug} was succesfully overwritten."
      response_for :update
    end
  end
end