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

Using after_initialize in engine #471

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juanmanuelramallo
Copy link

@juanmanuelramallo juanmanuelramallo commented Mar 25, 2024

Allows users to execute ruby code that consumes classes from app/models or any other portion of their app.

This is particularly helpful for creating smart columns for AR enums. i.e.:

# app/models/account.rb
class Account < ApplicationRecord
  enum state: [:pending, :setup, :succeded, :failed]
end

# config/blazer.yml
data_sources:
  main:
    smart_columns:
      account_state: <%= Account.states.to_h {|k,v| [v, k.titleize]}.to_json %>

Without this change, initialization fails with error "uninitialized constant Account (NameError)".

Allows users to execute ruby code that consumes classes
from app/models or any other portion of their app.

This is particularly helpful for creating smart columns for AR enums.
i.e.:

```ruby
 # app/models/account.rb
class Account < ApplicationRecord
  enum state: [:pending, :setup, :succeded, :failed]
end

 # config/blazer.yml
data_sources:
  main:
    smart_columns:
      account_state: <%= Account.states.to_h {|k,v| [v, k.titleize]}.to_json %>
```

Without this change, initialization fails with error "uninitialized
constant Account (NameError)".
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

Successfully merging this pull request may close these issues.

None yet

1 participant