Skip to content

Instantly share code, notes, and snippets.

@abhianair
Created November 16, 2018 11:08
Show Gist options
  • Save abhianair/0614e5649701a5f78463c422aae596c7 to your computer and use it in GitHub Desktop.
Save abhianair/0614e5649701a5f78463c422aae596c7 to your computer and use it in GitHub Desktop.
Enter Subdomain name inside input field and redirect to its domain if the subdomain present.
def proceed
@domain_from_form = params[:search][:q]
@domain_search = User.pluck(:subdomain)
@domain_present = @domain_search.include? @domain_from_form
if @domain_present == true
redirect_to "http://#{@domain_from_form}.lvh.me:3000/accounts/sign_in"
else
redirect_to resub_index_path
end
end
<h1>Enter the Subdomain</h1>
<%= form_for :search, :url => { :method => :get, :action => :proceed } do |f| %>
<%= f.label :q, "Enter the Subdomain" %>
<%= f.text_field :q %>
<%= f.submit "Proceed" %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment