Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax for accessing records via query #34

Closed
dvodvo opened this issue Nov 14, 2022 · 1 comment
Closed

Syntax for accessing records via query #34

dvodvo opened this issue Nov 14, 2022 · 1 comment

Comments

@dvodvo
Copy link

dvodvo commented Nov 14, 2022

giving the indices

add_index :action_text_rich_texts,              [:record_type, :record_id, :name, :locale]

and assuming a context of exporting a set of translated record_ids, what is the proper syntax for querying/accessing the table for such an array? struggled a bit with this for basic mobility

I believ it evolves from:
Mobility::Activerecord::StringTranslation
Mobility::Activerecord::TextTranslation
to
Mobility::Backends::ActionText::PlainTextTranslation
Mobility::Backends::ActionText::RichTextTranslation
?

Assuming klass.translatable_content column, how does one call a method, say

truncate(klass.translatable_content column, length: 200)

?

@sedubois
Copy link
Owner

Hi @dvodvo, thanks for writing in. Once you've set up Mobility and Action Text, your translated Action Text should be accessible using the standard Mobility APIs, e.g. record.content. A DB index is suggested to ensure fast access to the records and (optionally) to enforce uniqueness, but it doesn't impact the way to read/write attributes using the Mobility API.

If you have further questions, please feel free to reopen with code which allows to reproduce your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants