Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to output the current protocol and url using rails?

I have a share dialog.

On dev it looks like:

http://xxxxxx.com/stuff

On prod:

https://yyyyyyyyyyy.com/stuff

What's the best rails way to output #Protocol# #URL#

And where can I set these in rails? thanks

like image 498
AnApprentice Avatar asked Jul 20 '11 18:07

AnApprentice


People also ask

How do I get the current url in Ruby on Rails?

You should use request. original_url to get the current URL. Source code on current repo found here.

What is application controller in Rails?

The Rails controller is the logical center of your application. It coordinates the interaction between the user, the views, and the model. The controller is also a home to a number of important ancillary services. It is responsible for routing external requests to internal actions.

What does before action do in Rails?

If a "before" filter renders or redirects, the action will not run. If there are additional filters scheduled to run after that filter, they are also cancelled.


1 Answers

request.protocol
request.url

See the request object.

like image 73
Kyle Heironimus Avatar answered Oct 13 '22 01:10

Kyle Heironimus