actmd / abraham

Trackable application tours for Rails with i18n support
MIT License
124 stars 45 forks source link

How to handle controllers with the same name? #38

Closed marwann closed 3 years ago

marwann commented 3 years ago

Hi there,

Thanks for making Abraham :)

My issue is that I have some namespaced controllers / actions with the same name, eg. :

Namespaces aren't taken into account in Abraham so I had put my yml file inside tours/dashboard/index.en.yml which results in the tour displaying in both dashboards.

I've tried changing the initializer to take subfolders like tours/admin/dashboard/index.en.yml into account but with no luck, Abraham doesn't recognize the controller.

Any clue?

Thanks

scarroll32 commented 3 years ago

This could probably done fairly easily by referring to controller_path instead of controller_name when making the Ajax call:

  tour.on("complete", function() {
    // ajax
    return $.ajax({
      url: "/abraham_histories/",
      type: "POST",
      dataType: "json",
      contentType: "application/json",
      data: JSON.stringify({
        authenticity_token: '<%= form_authenticity_token %>',
        controller_name: '<%= controller_name %>',
        action_name: '<%= action_name %>',
        tour_name: '<%= tour_name %>'
      })
    });

Supporting changes would be needed in the controller and database table.

http://api.rubyonrails.org/classes/AbstractController/Base.html#method-i-controller_path

jabbett commented 3 years ago

Hi, @marwann! Thanks for your question and apologies for the frustration! We obviously didn't anticipate namespaces :(

I like @seanfcarroll's controller_path idea, though we'd have to figure out backward compatibility.

If we simple changed the code to use controller_path, applications that had already been using Abraham would suddenly see all their old tours reappear ;)

jabbett commented 3 years ago

@seanfcarroll We actually discussed this topic among our team this morning, we're going to test your solution out here and try to get it included ASAP ;)

scarroll32 commented 3 years ago

@jabbett glad it was helpful!

jabbett commented 3 years ago

The tricky part was rewriting the initializer to load the yaml files while retaining the controller path. But now that I've figured that out, I expect to get this tested and released today.

marwann commented 3 years ago

@jabbett, @seanfcarroll - Thanks for making this a reality. I'll update Abraham in the next few days :)