Here is the counters_controller.rb code :
class CountersController < ApplicationController
#require ‘colorize’
before_action :get_counter, only: [:show, :edit, :update, :destroy]
GET /counters
GET /counters.json
def index
end
GET /counters/1
GET /counters/1.json
def show
raw_counter = REDIS.hget(params[:id], 'c')
raw_counter_reset = REDIS.hget(params[:id], 'overquota_reset_c')
raw_counter_reset_date = REDIS.hget(params[:id],
‘overquota_reset_at’)
#@counter_max = ‘put’.red
#@counter_msg.red
@counter = {:id => params[:id]}
if raw_counter == ‘0’
@counter_msg = ‘0’
@counter_max = ‘0’
else
@counter_msg = raw_counter[9…17]
@counter_max = raw_counter[1…6]
#if @counter_msg > @counter_max
#end
end
if raw_counter_reset == "1"
@counter_reset = 'oui'
else
@counter_reset = 'non'
end
@counter_reset_date = Time.at(raw_counter_reset_date.to_i)
respond_to do |format|
format.html # show.html.erb
format.json { render json: @counter }
end
end
GET /counters/new
def new
@counter = Counter.new
end
GET /counters/1/edit
def edit
end
POST /counters
POST /counters.json
def create
@counter = Counter.new(counter_params)
respond_to do |format|
if @counter.save
format.html { redirect_to @counter, notice: 'Counter was
successfully created.’ }
format.json { render action: ‘show’, status: :created, location:
@counter }
else
format.html { render action: ‘new’ }
format.json { render json: @counter.errors, status:
:unprocessable_entity }
end
end
end
PATCH/PUT /counters/1
PATCH/PUT /counters/1.json
def update
respond_to do |format|
if @counter.update(counter_params)
format.html { redirect_to @counter, notice: ‘Counter was
successfully updated.’ }
format.json { head :no_content }
else
format.html { render action: ‘edit’ }
format.json { render json: @counter.errors, status:
:unprocessable_entity }
end
end
end
DELETE /counters/1
DELETE /counters/1.json
def destroy
@counter.destroy
respond_to do |format|
format.html { redirect_to counters_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between
actions.
def get_counter
@counter = REDIS.hget(params[:id], ‘c’)
end
# Never trust parameters from the scary internet, only allow the
white
list through.
def counter_params
#params.require(:counter).permit()
end
end
I don’t think the problem comes from contôler and raw_counter,
because when I replace :
<%= form_tag ‘/counters/id’, method: :get %>
by:
<%= form_tag ‘/counters/ovm%3Ab%3A%7Bpausecho%7D%2Fmozilla’, method:
:get %>
of index.html.erb,the application works, and shows it :
with this URL :
http://127.0.0.1:3000/counters/ovm%3Ab%3A{pausecho}%2Fmozilla?utf8=✓&counters=&commit=Search