Open muhammetfaik opened 5 years ago
Hi, Can you help to support new version mongoid.
gem "mongoid-enum", :git => 'https://github.com/choilive/mongoid-enum.git'
I have updated it to support mongoid 7, looks like the maintainer is inactive for this project
@choilive pretty cool but I get errors if I try to install it I got ruby 3.0.0
current directory: ...../.rvm/gems/ruby-3.0.0/gems/bigdecimal-1.4.4/ext/bigdecimal
make "DESTDIR="
compiling bigdecimal.c
bigdecimal.c:421:5: error: implicit declaration of function 'rb_check_safe_obj' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
rb_check_safe_obj(str);
^
bigdecimal.c:421:5: note: did you mean 'rb_check_safe_str'?
/Users/timopurzner/.rvm/rubies/ruby-3.0.0/include/ruby-3.0.0/ruby/internal/core/rstring.h:97:6: note: 'rb_check_safe_str' declared here
void rb_check_safe_str(VALUE);
^
bigdecimal.c:2030:6: error: implicit declaration of function 'rb_check_safe_obj' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
rb_check_safe_obj(f);
^
2 errors generated.
make: *** [bigdecimal.o] Error 1
@ZeroSoulEater hm yes, this gem depends on bigdecimal 1.4.x which is not compatible with ruby 3, I'll try upgrading bigdecimal 2.0 and see if it still works.
gem "mongoid-enum", :git => 'https://github.com/choilive/mongoid-enum.git'
I have updated it to support mongoid 7, looks like the maintainer is inactive for this project
Hey @choilive, thanks for update it!
I'm having problems on use the enum.
Basically my model have this field called type, like that:
field :type, type: Integer
Which will be a enum:
enum type: { type_1: 0, type_2: 1, type_3: 2 }
But i'm facing this error when I try to make a request passing type: "type_1"
:
"exception": "#<ArgumentError: wrong number of arguments (given 1, expected 2..3)>",
Any idea?
@jramiresbrito hey! it looks like you are trying to use enums in the style of ActiveRecord Enums, I dont think you can explicitly map between the attribute and the value in the same way here. The mongoid-enum gem does not try to be the same api as activerecord enum (it also came way before that was released)
something like enum :type, [:type_1, :type_2, :type_3]
should work
@ZeroSoulEater hm yes, this gem depends on bigdecimal 1.4.x which is not compatible with ruby 3, I'll try upgrading bigdecimal 2.0 and see if it still works.
hey , is this working for ruby 3 ?,still showng error for me
@choilive Hey friend! It's been some time now. How's it working for MongoId 8?
Help !!!