I have a custom validator that I want to apply to several attributes in the same model right now I the following the works just fine: But when I t ...
I have a custom validator that I want to apply to several attributes in the same model right now I the following the works just fine: But when I t ...
I have a class Person that has first_name, middle_name, last_name. I have a customed Each validator for these 3 attributes like so In this validato ...
I found two alternatives to make use of the ActiveModel::Validator helper, but I am failing to find an easier or clean(er) approach than either checki ...
Mongoid won't save document with no reference to embeds_many field, and I can't find any mention in documentation on how to make embeds_many default t ...
I'm using Rails 7 and Ruby 3.1, and Shoulda Matchers for tests, but not Active Record, for I do not need a database. I want to validate numericality. ...
I have an object that uses the ActiveModel::Model concepts: Underneath the covers, this object is an aggregate for a Provider record and a Service ...
While trying to upgrade my application to Rails 7, I came across the following deprecation warning : ActiveRecord::Base.default_timezone is depreca ...
I am trying to build an invitation system for my app and I feel like there's a nice way to do what I need, yet I'm not sure about it. I have a User m ...
I’m using Rails 4.2. It is not an option to upgrade at this time. I have this model How do I initialize my object by referencing my enum? I tried t ...
I have product as active record table and option_type as activemodel model. option types is an array of objects as follows, I want to desing a form ...
I'm trying to run rails with jruby rails : 6.1.4.4 | jruby : 9.3.3.0 | ruby : 2.6.8 I get this error for when i try to use any Model(s) In rails cons ...
I have an existing simple rails app that I'm trying to modify. I'm working on getting an ActiveModel model to work in this app (existing models all us ...
I got a little bit of a challenge but I don't know where to start. Long story short, I'm trying to make a method that will automatically translate a r ...
I have a Rails 6 app. User.update with nested_attributes purges the User.shop.company_logo. class User has_one :shop, dependent: :destroy # dele ...
in Rails6 I think one comment mentioned that I can only use Migrations to assign attributes to a model. (i.e. the columns from my migration for a mode ...
Is it possible to decide which type casts an attribute in ActiveModel::Attributes on runtime? I have the following code I'd like to decide based on ...
I have a record with accepts_nested_attributes_for and after creation I want to get the ids and attributes of the created records without making anoth ...
The AnimalSerializer sits in animal_engine/app/serializers/api_handler/api/private/mobile_app/v8 Weirdly serializing a single item works. I get th ...
is it possible to Sanitize the params transfered from the controller in the model? Let's say I have this Controller: and this model: In this mo ...
For a project, I need the categories attribute of the Post class to be either "Fiction" or "Non-Fiction." I attempted the following syntax... but i ...