Questions tagged [enumerize]

Enumerated attributes with I18n and ActiveRecord/Mongoid/MongoMapper support

Enumerated attributes with I18n and ActiveRecord/Mongoid/MongoMapper support

https://github.com/brainspec/enumerize

12 questions
4
votes
2 answers

How to validate presence of an array using Enumerize?

I'm trying to implement to validations on a given model array-like field, using the Enumerize Gem. I want to: validate that all the elements of a list belong to a given subset, using Enumerize validate that the list is not empty (using validates…
Benjamin Cbr
  • 536
  • 4
  • 13
2
votes
1 answer

How to get the integer value from enumerize inside a rabl template?

I have the follow model using enumerize gem: class Event < ActiveRecord::Base extend Enumerize enumerize :code, in: {dummy: 0, none: 1, panic: 2 } end This rabl file returns the strings "dummy", "none" and "panic: object @event attributes…
Ricardo
  • 667
  • 9
  • 25
1
vote
1 answer

Can't display sign '-' with rails enumerize

I am using enumerize in my rails app. In model/user : enumerize :ranking, in: ['- 2/6', '- 4/6', '- 15', '- 30'] in my views I have user/edit.html.erb I have <%= simple_form_for(@user) do |f| %> <%= f.input :ranking, label: "Classement"…
David Geismar
  • 3,152
  • 6
  • 41
  • 80
1
vote
1 answer

Enumerize for a hash in a model

I'm using gem enumerize in my project. For now I have this: class MyAddress < ActiveRecord::Base enumerize :country, in: [:country1, :country2, :country3], default: :country2 end Now I want to convert state to be enumerize. Obviously, each…
Incerteza
  • 32,326
  • 47
  • 154
  • 261
0
votes
1 answer

How to make active record queries when attributes uses enumerize

class AppointmentResponse < ActiveRecord::Base ... extend Enumerize enumerize :status, in: %i[unreviewed approved rejected], default: :unreviewed ... end Migration: def change add_column :appointment_responses, :status, :string end So with…
coda
  • 163
  • 1
  • 9
0
votes
0 answers

rake db:seed aborted (uninitialized constant ActiveRecord::Type)

I got a new project, and running the seed files (rake db:seed) gives me this error: rake aborted! NameError: uninitialized constant ActiveRecord::Type /Users/mekto/.gem/ruby/2.1.4/gems/enumerize-2.1.2/lib/enumerize/activerecord.rb:69:in…
Tomislav Mikulin
  • 5,306
  • 4
  • 23
  • 36
0
votes
0 answers

NoMethodError: undefined method `empty?' for 0:Fixnum

It works fine on my local machine but gives following error in rails_admin on Heroku. Here's how I'm using enumerize enumerize :date_type, in: { last_date: 0, begin_date: 1 }, default: :last_date, predicates: { prefix: true,…
lightsaber
  • 1,481
  • 18
  • 37
0
votes
1 answer

Randomly showing NoMethodError: undefined method `empty?' for 0:Fixnum

It works fine on my local machine but gives following error in rails_admin on Heroku, using Puma web server. Here's how I'm using enumerize enumerize :date_type, in: { last_date: 0, begin_date: 1 }, default: :last_date,…
lightsaber
  • 1,481
  • 18
  • 37
0
votes
2 answers

How to access YML file in rails

I have set up a settings.yml file in my config folder with some list elements I want to pass to my enumerize in my rails model : config/ settings.yml enumerize: hotel_status: - "Hotel Privé" - "Bâtiment Publique" - "CHRS" - "CADA" …
David Geismar
  • 3,152
  • 6
  • 41
  • 80
0
votes
1 answer

Enumerize in Rails

I am trying to use Enumerize for attributes I defined. in my Student Model extend Enumerize attr_accessor :order_by enumerize :order_by, in: %w[time grade school], i18n_scope: "order_by_options" in my view (which is part of a form_tag) <%=…
Tiamon
  • 237
  • 2
  • 13
0
votes
1 answer

Allow rails-bootstrap-form collection to accept enumerize values

I am trying to drop in enum values setup with the 'Enumerize' gem into the radio collection select field on a rails-bootstrap-form. An example is shown how to do this with an ActiveRecord collection. How should I modify the example <%=…
Jay Killeen
  • 2,832
  • 6
  • 39
  • 66
-2
votes
1 answer

Create a bulletin board on Ruby on Rails

It is necessary to write a bulletin board with the division of ads by category (the ad can be in different categories at the same time). Ads must have several statuses (moderation / approved / rejected), only the administrator can change the…
Максим
  • 23
  • 1
  • 7