app/controllers/api/json/tables_controller.rb
# Very basic controller method to simply make blank tables
# All other table creation things are controlled via the imports_controller#create
Very basic controller method to simply make blank tables
All other table creation things are controlled via the imports_controller#create
Very basic controller method to simply make blank tables All other table creation things are controlled via the imports_controller#create
def create
    @table = Table.new
    @table.user_id        = current_user.id
    @table.name           = params[:name]          if params[:name]
    @table.description    = params[:description]   if params[:description]
    @table.the_geom_type  = params[:the_geom_type] if params[:the_geom_type]
    @table.force_schema   = params[:schema]        if params[:schema]
    @table.tags           = params[:tags]          if params[:tags]
    @table.import_from_query = params[:from_query]  if params[:from_query]
    if @table.valid? && @table.save
      @table = Table.where(id: @table.id).first
      render_jsonp(@table.public_values, 200, { location: "/tables/#{@table.id}" })
    else
      CartoDB::Logger.info "Error on tables#create", @table.errors.full_messages
      render_jsonp( { :description => @table.errors.full_messages,
                      :stack => @table.errors.full_messages
                    }, 400)
    end
  rescue CartoDB::QuotaExceeded => exception
    render_jsonp({ errors: [TABLE_QUOTA_REACHED_TEXT]}, 400)
  end
def create @table = Table . new @table . user_id = current_user . id @table . name = params [ :name ] if params [ :name ] @table . description = params [ :description ] if params [ :description ] @table . the_geom_type = params [ :the_geom_type ] if params [ :the_geom_type ] @table . force_schema = params [ :schema ] if params [ :schema ] @table . tags = params [ :tags ] if params [ :tags ] @table . import_from_query = params [ :from_query ] if params [ :from_query ] if @table . valid? && @table . save @table = Table . where ( id : @table . id ) . first render_jsonp ( @table . public_values , 200 , { location : "/tables/#{@table.id}" } ) else CartoDB :: Logger . info "Error on tables#create" , @table . errors . full_messages render_jsonp ( { :description => @table . errors . full_messages , :stack => @table . errors . full_messages } , 400 ) end rescue CartoDB :: QuotaExceeded => exception render_jsonp ( { errors : [ TABLE_QUOTA_REACHED_TEXT ] } , 400 ) end
Very basic controller method to simply make blank tables
All other table creation things are controlled via the imports_controller#create
Very basic controller method to simply make blank tables All other table creation things are controlled via the imports_controller#create