Class: DatastoreRedis::RedisStringsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/datastore_redis/redis_strings_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /redis_strings POST /redis_strings.json



44
45
46
47
48
49
50
51
# File 'app/controllers/datastore_redis/redis_strings_controller.rb', line 44

def create
  RedisString.create(params['redis_key'], params['redis_value'])
  
  respond_to do |format|
      format.html { redirect_to redis_string_path(params['redis_key']),  notice: 'Redis string was successfully created.' }
      format.json { render json: params['redis_value'], status: :created, location: @redis_string }
  end
end

#destroyObject

DELETE /redis_strings/1 DELETE /redis_strings/1.json



71
72
73
74
75
76
77
78
79
# File 'app/controllers/datastore_redis/redis_strings_controller.rb', line 71

def destroy
  @redis_key = params[:id]
  RedisString.destroy(@redis_key)
  
  respond_to do |format|
    format.html { redirect_to redis_strings_url }
    format.json { head :ok }
  end
end

#editObject

GET /redis_strings/1/edit



37
38
39
40
# File 'app/controllers/datastore_redis/redis_strings_controller.rb', line 37

def edit
  @redis_key = params[:id]
  @redis_value = RedisString.find(@redis_key)
end

#indexObject

GET /redis_strings GET /redis_strings.json



5
6
7
8
9
10
11
12
# File 'app/controllers/datastore_redis/redis_strings_controller.rb', line 5

def index
  @redis_strings = RedisString.all
  
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @redis_strings }
  end
end

#newObject

GET /redis_strings/new GET /redis_strings/new.json



28
29
30
31
32
33
34
# File 'app/controllers/datastore_redis/redis_strings_controller.rb', line 28

def new
  
  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: ''}
  end
end

#showObject

GET /redis_strings/1 GET /redis_strings/1.json



16
17
18
19
20
21
22
23
24
# File 'app/controllers/datastore_redis/redis_strings_controller.rb', line 16

def show
  @redis_key = params[:id]
  @redis_value = RedisString.find(@redis_key)
  
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @redis_value }
  end
end

#updateObject

PUT /redis_strings/1 PUT /redis_strings/1.json



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/datastore_redis/redis_strings_controller.rb', line 55

def update
  @redis_string = RedisString.find(params[:id])
  
  respond_to do |format|
    if @redis_string.update_attributes(params[:redis_string])
      format.html { redirect_to redis_string_path(@redis_string), notice: 'Redis string was successfully updated.' }
      format.json { head :ok }
    else
      format.html { render action: "edit" }
      format.json { render json: @redis_string.errors, status: :unprocessable_entity }
    end
  end
end