【发布时间】:2015-11-11 00:45:30
【问题描述】:
我正在尝试显示活动和待处理呼叫总数的数值。目前我将这些分成两个面板,并希望包括一个可见的数字来显示每种类型中有多少在 que 中。
我已经对此进行了搜索,但它非常复杂,没有多大意义。
列名是“status”,在通话创建页面中可以选择“assigned”和“pending”
以下是我的控制器供参考。
调用控制器:
class CallsController < ApplicationController
before_action :set_call, only: [:show, :edit, :update, :destroy]
# GET /calls
# GET /calls.json
def index
@calls = Call.all
@active_calls = Call.where(status: 'active')
@pending_calls = Call.where(status: 'pending')
end
# GET /calls/1
# GET /calls/1.json
def show
end
# GET /calls/new
def new
@call = Call.new
end
# GET /calls/1/edit
def edit
end
# POST /calls
# POST /calls.json
def create
@call = Call.new(call_params)
respond_to do |format|
if @call.save
format.html { redirect_to @call, notice: 'Call was successfully created.' }
format.json { render :show, status: :created, location: @call }
else
format.html { render :new }
format.json { render json: @call.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /calls/1
# PATCH/PUT /calls/1.json
def update
respond_to do |format|
if @call.update(call_params)
format.html { redirect_to @call, notice: 'Call was successfully updated.' }
format.json { render :show, status: :ok, location: @call }
else
format.html { render :edit }
format.json { render json: @call.errors, status: :unprocessable_entity }
end
end
end
# DELETE /calls/1
# DELETE /calls/1.json
def destroy
@call.destroy
respond_to do |format|
format.html { redirect_to calls_url, notice: 'Call was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_call
@call = Call.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def call_params
params.require(:call).permit(:call_time, :status, :primary_type, :secondary_type, :site, :address, :unit_1, :unit_2, :unit_3, :unit_4, :call_details, :unit_on_scene, :unit_clear, :call_num, :site_id)
end
end
Postgresql 方面是我的弱点,我目前正在努力加强这一点。
提前感谢您的帮助。
【问题讨论】:
标签: html css ruby postgresql ruby-on-rails-4