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

URL-Path to / when mounted on /pages #1918

Closed
ingedmundo opened this issue Aug 4, 2020 · 5 comments · Fixed by #1919 or #1921
Closed

URL-Path to / when mounted on /pages #1918

ingedmundo opened this issue Aug 4, 2020 · 5 comments · Fixed by #1919 or #1921

Comments

@ingedmundo
Copy link

Steps to reproduce

image

My alchemy is mounted on /pages:

mount Alchemy::Engine => 'pages'

But url path of pages are pointing to \ instead of \pages causing linkeable elements to point to the wrong place.

Expected behavior

linkeable elements should point to /

System configuration

  • Alchemy Version: gem 'alchemy-solidus', '~> 3.0.2'
  • Rails Version: gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
@github-actions
Copy link

github-actions bot commented Aug 4, 2020

Hey. Thanks for reporting this issue and welcome to AlchemyCMS. The maintainer have been notified. Please be patient while waiting for an answer. Open Source is done by volunteers, so give them some time to react. Meanwhile please think about sending a PR that fixes this issue. It is way more likely that it will be accepted than this bug fixed for you. Remember OpenSource is done by all of us. Again, thanks for reporting.

@ingedmundo
Copy link
Author

Looking for guidance on this and all alchemy related topic I get to https://gitter.im/AlchemyCMS - can someone tell me if this is the right place to ask for help.

@tvdeyen
Copy link
Member

tvdeyen commented Aug 6, 2020

Please join us on Slack as noted in the README and the homepage.

@tvdeyen
Copy link
Member

tvdeyen commented Aug 6, 2020

Ideally Alchemy would have build in support for this, but unfortunately it is pretty hard for a Rails engine to read its own mount point.

The easiest fix for your problem would be to add your own UrlPath class and and overwrite the one provided by Alchemy.

class MyOwn::UrlPath < Alchemy::Page::UrlPath
  def call
    "/pages" + super
  end
end
# app/models/alchemy/page_decorator.rb
module Alchemy
  module PageDecorator
    def url_path
      MyOwn::UrlPath.new(self).call
    end

    Page.prepend(self)
  end
end

Will provide a PR that make setting a custom UrlPath class easier, but for now the decorator should do the trick in a Solidus environment.

tvdeyen added a commit to tvdeyen/alchemy_cms that referenced this issue Aug 6, 2020
tvdeyen added a commit to tvdeyen/alchemy_cms that referenced this issue Aug 7, 2020
If an app mounts Alchemy at a non-root path we need to return that as prefix.

Closes AlchemyCMS#1918
tvdeyen added a commit that referenced this issue Aug 7, 2020
If an app mounts Alchemy at a non-root path we need to return that as prefix.

Closes #1918
tvdeyen added a commit to tvdeyen/alchemy_cms that referenced this issue Aug 7, 2020
@tvdeyen
Copy link
Member

tvdeyen commented Aug 7, 2020

It turned out that it was pretty east to add support for custom mount points in the url path class. Latest master branch has it already included. You can use it like this

# Gemfile

gem "alchemy_cms", github: "https://github.com/AlchemyCMS/alchemy_cms", branch: "master"

tvdeyen added a commit that referenced this issue Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants