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

Can't access models/order.rb from order_dashboard.rb #1720

Closed
kesha-antonov opened this issue Jul 22, 2020 · 3 comments
Closed

Can't access models/order.rb from order_dashboard.rb #1720

kesha-antonov opened this issue Jul 22, 2020 · 3 comments
Labels
bug breakages in functionality that is implemented

Comments

@kesha-antonov
Copy link

Hi!

class OrderDashboard < Administrate::BaseDashboard
  ATTRIBUTE_TYPES = {
    id: Field::Number,
    state: SelectField.with_options(options: ApplicationRecord::Order.aasm(:state).states.map(&:name).map{|x| [I18n.t("orders.state.#{x}"), x]}, include_blank: true),

I can't access Order from OrderDashboard. Because if I use Order without ApplicationRecord:: it uses Order.rb from administrate. But ApplicationRecord:: doesn't work either.

Can you help me please get access to Order from models?

  • What versions are you running?
    • Rails 5.1.4
    • administrate 0.14.0
@kesha-antonov kesha-antonov added the bug breakages in functionality that is implemented label Jul 22, 2020
@sedubois
Copy link
Contributor

Seems like a similar issue to #1709?

@kesha-antonov
Copy link
Author

@sedubois yeah, I think

Now I use ::Order. It helped to use Order from models/order.rb

@pablobm
Copy link
Collaborator

pablobm commented Jul 23, 2020

It's not the same as #1709. Using ::Order is the correct fix here. It's a common issue when working with similarly-named modules in Ruby.

I think this solves it, so I'll close. Let me know if you think otherwise.

@pablobm pablobm closed this as completed Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug breakages in functionality that is implemented
Projects
None yet
Development

No branches or pull requests

3 participants