Class: ChikkenInaBukket::Controllers::Index

Inherits:
R
  • Object
show all
Defined in:
lib/chikken_in_a_bukket.rb

Instance Method Summary collapse

Instance Method Details

#getObject



135
136
137
138
139
140
141
142
# File 'lib/chikken_in_a_bukket.rb', line 135

def get
  unless Config.configured?
    return redirect(Configuration)
  else
    @buckets = Config.connection.bucket_names
    render :index
  end
end

#postObject



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/chikken_in_a_bukket.rb', line 144

def post
  begin
    @bucket = Config.connection.create_bucket(@input[:bucket])
    @objs = []
    return redirect(Buckets, @bucket.name)
  rescue S33r::S3Exception::S3OriginatedException => e
    @buckets = Config.connection.bucket_names
    if e.s3_code == 'BucketAlreadyExists'
      @flash = "Sorry, the bucket #{@input[:bucket]} already exists. Try another name."
    else
      @flash = "Error #{e.s3_message}"
    end
    render :index
  end
end