Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
Finding specific type of user in rails app, postgresql

I´m learning ROR by building an app. In my user.rb model I have a four type of users every user can select on Sign up using f.select on the sign up view.

The problem is if I would like to, for an example know How many users are in the industry type 'Heavy' ? Or What is the average :staffcount for the users in the Medium class? I´m not sure how to do that.

This is what I got so far to find the numbers of users in the Heavy class @heavy_users = User.where(industry_type: 'Heavy']).count but with no luck.

can someone be so kind and help me with this?

user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable

     INDUSTRY_TYPES = [['Heavy'], ['Medium'], ['Light'], ['Dirty']]
end

here is the the new.html.erbform for the sign up:

<h2>Sign up</h2>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<div class="field">
 <%= f.label :username %><br />
 <%= f.text_field :username, autofocus: true %>
</div>
<div class="field">
 <%= f.label :email %><br />
 <%= f.email_field :email %>
</div>

<div class="field">
 <%= f.label :staffcount %><br />
 <%= f.number_field :staffcount %>
</div>

<div class="field">
 <%= f.label :industry_type %>
 <%= f.select(:industry_type, options_for_select(User::INDUSTRY_TYPES)) %>
</div>

<div class="field">
 <%= f.label :password %>
 <% if @minimum_password_length %>
 <em>(<%= @minimum_password_length %> characters minimum)</em>
 <% end %><br />
 <%= f.password_field :password, autocomplete: "off" %>
</div>

<div class="field">
 <%= f.label :password_confirmation %><br />
 <%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>

 <div class="actions">
  <%= f.submit "Sign up" %>
 </div>
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda