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

Error while using Administrate when Ahoy is already installed in App #2689

Open
kapilpdev opened this issue Oct 24, 2024 · 6 comments
Open
Labels
bug breakages in functionality that is implemented

Comments

@kapilpdev
Copy link

kapilpdev commented Oct 24, 2024

  • What were you trying to do?
    I was trying to see the user page in the administrate dashboard and it throws me an error
    i can see the index of users but when i click on a specific user it give me this error:
    Ahoy is tracking every action, so whenever I try to open any model's show page this error is shown
  • What did you end up with (logs, or, even better, example apps are great!)?

Screenshot from 2024-10-24 17-13-26

Screenshot from 2024-10-24 17-10-53

  • What versions are you running?
    • Rails 7.2.1
    • administrate 0.20.1
@kapilpdev kapilpdev added the bug breakages in functionality that is implemented label Oct 24, 2024
@nickcharlton
Copy link
Member

Thanks for opening this!

Could you be able to setup an example project in a repo somewhere where I can try out this particular situation? I've not used Ahoy before, so I don't know how it might be, but it seems like it's clashing somewhere.

@kapilpdev
Copy link
Author

Hey @nickcharlton I have made this sample project with user model
https://github.com/kapilpdev/administrate-ahoy

@srbaker
Copy link

srbaker commented Nov 5, 2024

I'm sure this is because the Visit model from ahoy lives in Ahoy::Visit, and aministrate doesn't support namespaced model names (yet).

@nickcharlton
Copy link
Member

@kapilpdev, thank you! I'll take a look soon.

@srbaker, yeah, that's likely it. It does support a lot more than it did, but we might have just found a situation where it's not working.

@nickcharlton
Copy link
Member

Sorry this took me ages. I've been trying to get everything ready for v1, and I knew this would take a bit of time to dig into. Thanks for the example application, I tried that out, and it really helped me understand how it's breaking.

I tried with 0.20.1, as you'd set up with, and also 1.0.0.beta2 (I was curious if it was indeed just a namespacing issue we might've fixed). It's not, though, and is actually a good opportunity to build a custom field type.

It's breaking because Administrate expects a belongs_to field to have a dashboard to go with it. You can generate one with: rails g administrate:dashboard Ahoy::Visit.

You may also have to do something like this (I tried this first before realising):

ATTRIBUTE_TYPES = {
    id: Field::Number,
    ahoy_visit: Field::BelongsTo.with_options(class_name: "Ahoy::Visit"),
}

I was able to get it to render a dashboard that looks like this:

Screenshot 2024-11-25 at 12 46 48

I presume that's not actually helpful though, what would you expect a field like this to show?

@kapilpdev
Copy link
Author

@nickcharlton Naturally Ahoy visits generate automatically as it stores the activities of a user. Each new visit stores data such as: the user navigated from one page to another in the application, the user clicked a button, or the user created a new object.

So in my project I was not able to create a Dashboard for the Ahoy Visits, and because of the same reason I had to remove all the ahoy visit references from all the dashboard of the models it was associated to.

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