ActiveModel::Attributes (array: true) - should it require Postgres?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveModel::Attributes (array: true) - should it require Postgres?

Patrick Davey
Hi,

I'm really enjoying using the new ActiveModel::Attributes API for making form objects (replacing Virtus).

At the moment, if you want to do :

class Foo
  include
ActiveModel::Model
  include
ActiveModel::Attributes

  attribute
:bars, :string, array: true

you _must_ be using the `postgresql` adapter and further, it _seems_ you can only do this on a "real" schema backed model (i.e. the above won't work, even if you were using postgres)

I'm wondering if this is likely to change (i.e. if there'll be a feature for non-database backed models that you'll be able to use these "ActiveRecord::Type modifiers" on ActiveModels as well. Seems to me that it should be possible to make it so that it's not coupled to a particular database schema. That said, I find this all quite tricky stuff so I'm almost certainly missing something ;)

Thanks,
Patrick

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ace1f4a0-c703-49b1-b6be-4805f11e9ecb%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveModel::Attributes (array: true) - should it require Postgres?

San Ji
ActiveModel is agnostic to the database, you can use it without using any database, so no, it should not require Postgres.

I believe
array: true
on an ActiveRecord model, with MySQL, or SQLite, is possible too.
Just combine it with "serialize"

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/80dcb9b2-b60a-4062-824b-cc297d665f05%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveModel::Attributes (array: true) - should it require Postgres?

San Ji

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/439ffc74-10af-4f35-950d-c161256cdb1a%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveModel::Attributes (array: true) - should it require Postgres?

Patrick Davey
Thanks for the reply San Ji :)

ActiveModel is database agnostic, however, the `attribute :foo, :my_custom_type, array: true` syntax [from the new activerecord::attributes api](https://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html) is only available to postgres, [as it's defined on the postgres adapter](https://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute-label-Options)

Possibly my question should be put to the core-team mailing list, as, really I'm wondering about whether the feature should be built in.

On Mon, 12 Aug 2019 at 04:18, San Ji <[hidden email]> wrote:

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/439ffc74-10af-4f35-950d-c161256cdb1a%40googlegroups.com.


--

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANQ7O3E2MRdk6c3apSxzSFjjcM%3Dw2nUfHwibObP7xzbM_h6NeQ%40mail.gmail.com.