# Ruby in Rails -- Redirect to Login

**URL:** <https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320>\
**Category:** Get Help\
**Tags:** rails\
**Created:** [September 7, 2020, 5:19am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320 "2020-09-07T05:19:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shane-nzpost](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shane-nzpost/32/13031_2.png) [@shane-nzpost](https://community.auth0.com/u/shane-nzpost)\
**Post date:** [September 7, 2020, 5:19am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320/1 "2020-09-07T05:19:37Z")

</div>

Hi

I have been following the tutorial for using Auth0 with Rails here [https://auth0.com/docs/quickstart/webapp/rails/01-login](https://auth0.com/docs/quickstart/webapp/rails/01-login)

The issue I have is that most Rails applications (and ours is one of them) , if I hit a URL that needs a login, it will redirect me to the login screen, and then upon successful authentication continue on it’s merry journey.

I haven’t found anything in the documentation about how to do that redirect?

I have had to construct a URL myself … that seems to work … but it’s been a bit of trial and error and I would have thought that there was a better Rails way.

```
state = SecureRandom.hex
session['omniauth.state'] = state
callback_url = auth_auth0_callback_url
url = "https://#{ApplicationConfig::Auth0::DOMAIN}/authorize?response_type=code&client_id=#{ApplicationConfig::Auth0::CLIENT_ID}&redirect_uri=#{callback_url}&state=#{state}&scope=openid profile email"

```

So is there a better way of doing this?

Cheers  
Shane

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 7, 2020, 6:42am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320/2 "2020-09-07T06:42:30Z")

</div>

Hey there Shane!

It would be best if you open a GitHub issue in the quickstart repo so the quickstart maintainers can address that directly for you. Make sure to share the link to it here with us so we can ping them. Thanks!

---

<div class="post-metadata">

**Author:** ![shane-nzpost](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shane-nzpost/32/13031_2.png) [@shane-nzpost](https://community.auth0.com/u/shane-nzpost)\
**Post date:** [September 7, 2020, 7:50am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320/3 "2020-09-07T07:50:00Z")

</div>

Hi Konrad

I submitted an issue as you suggested. [Ruby in Rails – Redirect to Login · Issue #105 · auth0/omniauth-auth0 · GitHub](https://github.com/auth0/omniauth-auth0/issues/105)

Thanks  
Shane

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 7, 2020, 8:59am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320/4 "2020-09-07T08:59:19Z")

</div>

but you should have opened it here:

[https://github.com/auth0-samples/auth0-rubyonrails-sample/tree/master/01-Login](https://github.com/auth0-samples/auth0-rubyonrails-sample/tree/master/01-Login)

as this is the repo for the quickstart you use.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 7, 2020, 10:02am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320/5 "2020-09-07T10:02:06Z")

</div>

Share the link to the issue once you have it and please the previous one you opened in another repo.

---

<div class="post-metadata">

**Author:** ![shane-nzpost](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shane-nzpost/32/13031_2.png) [@shane-nzpost](https://community.auth0.com/u/shane-nzpost)\
**Post date:** [September 7, 2020, 10:12am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320/6 "2020-09-07T10:12:07Z")

</div>

Ok, Here is issue [Ruby in Rails – Redirect to Login · Issue #43 · auth0-samples/auth0-rubyonrails-sample · GitHub](https://github.com/auth0-samples/auth0-rubyonrails-sample/issues/43)

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 7, 2020, 10:18am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320/7 "2020-09-07T10:18:52Z")

</div>

Thank you! I will ping repo maintainers in a few minutes!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 22, 2020, 10:18am UTC](https://community.auth0.com/t/ruby-in-rails-redirect-to-login/49320/8 "2020-09-22T10:18:56Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
