-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Space: BYO Domains drop Space from polymorphic_urls #1000
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,38 @@ class ApplicationController < ActionController::Base | |
|
||
helper_method :current_person | ||
|
||
helper_method def url_for(options) | ||
space = if options[0].is_a?(Space) && options[0].branded_domain.present? | ||
options.delete_at(0) | ||
elsif [:edit, :new].include?(options[0]) && options[1].is_a?(Space) && options[1].branded_domain.present? | ||
options.delete_at(1) | ||
elsif options.is_a?(Space) && options.branded_domain.present? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it is worth it, or if it would make the code even harder to understand, but these checks for "is this a Space and does it have a branded domain" could be tightened up like: thing_were_checking.try(:branded_domain).present? Which is a little bit more flexible (will work for any object that has a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always forget about |
||
options | ||
end | ||
|
||
if space | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could return early There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I need to |
||
if options.respond_to?(:last) && options.last.is_a?(Hash) | ||
options.last[:domain] = space.branded_domain | ||
elsif options.respond_to?(:<<) && options.length > 0 | ||
options << {domain: space.branded_domain} | ||
else | ||
options = [:root, {domain: space.branded_domain}] | ||
end | ||
end | ||
|
||
super | ||
end | ||
|
||
helper_method def polymorphic_path(options, **attributes) | ||
if options[0].is_a?(Space) && options[0].branded_domain.present? && options.length > 1 | ||
options.delete_at(0) | ||
elsif [:edit, :new].include?(options[0]) && options[1].is_a?(Space) && options[1].branded_domain.present? | ||
options.delete_at(1) | ||
end | ||
|
||
super | ||
end | ||
|
||
private | ||
|
||
OPERATOR_TOKEN = ENV["OPERATOR_API_KEY"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
module RoomsHelper | ||
def end_call_path(space) | ||
if space.branded_domain.present? | ||
"https://#{space.branded_domain}/" | ||
else | ||
space_path(space) | ||
end | ||
[space] | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two methods are arcane enough that I think they warrant at least a one-sentence comment explaining that they augment the standard Rails helpers to make URLs on branded domains nicer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I've linked to the core docs and included a sentance.