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

Allow for passing query parameters with embed link #3

Open
jronallo opened this issue Aug 27, 2022 · 0 comments
Open

Allow for passing query parameters with embed link #3

jronallo opened this issue Aug 27, 2022 · 0 comments

Comments

@jronallo
Copy link

I'm allowing users to embed some search results so need to pass the query parameters with the embed code. It would be nice to have the option to pass either all query parameters or an allowed list of query parameters with the embed code.

I worked around this limitation with this initializer.

require 'embed_me'
module EmbedMe
  module LinkHelper
    def current_page_embed_url
      # return if no link available
      return nil unless embedded_link_available?(request.path)

      # get current link
      current_page = merged_embedded(request.path)
      current_page.merge!({only_path: false})
      current_page.merge!({params: request.query_parameters}) # This is the line that does the trick
      url_for(current_page)
    end
  end
end
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

No branches or pull requests

1 participant