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

Add redirect_to method allowing redirects within a namespace #180

Merged
merged 1 commit into from May 4, 2016

Conversation

Projects
None yet
3 participants
@stjhimy
Contributor

stjhimy commented Dec 4, 2015

To avoid patching the redirect method I added redirect_to allowing requests to be redirected within the namespace:

       namespace '/admin' do
         get '/foo'  do
           redirect_to '/bar' # Redirects to /admin/bar
         end

         get '/foo' do
           redirect '/bar' # Redirects to /bar
         end
       end

(edited some typo on the code snippet)

@TrevorBramble TrevorBramble changed the title from Add reredict_to method allowing redirects within a namespace to Add redirect_to method allowing redirects within a namespace Dec 11, 2015

@stjhimy

This comment has been minimized.

Show comment
Hide comment
@stjhimy

stjhimy Apr 12, 2016

Contributor

@TrevorBramble I updated the commit with some example usage and rebased against master. Build is passing now.

Contributor

stjhimy commented Apr 12, 2016

@TrevorBramble I updated the commit with some example usage and rebased against master. Build is passing now.

@zzak zzak merged commit 2d5f886 into sinatra:master May 4, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@stjhimy stjhimy deleted the stjhimy:redirect_to branch Jul 20, 2016

zzak added a commit to zzak/sinatra-contrib that referenced this pull request Jul 22, 2016

Merge pull request #180 from stjhimy/redirect_to
Add redirect_to method allowing redirects within a namespace
@Nakilon

This comment has been minimized.

Show comment
Hide comment
@Nakilon

Nakilon Nov 28, 2016

This

namespace "/lab" do
  namespace "/dpap" do
    get "" do
      redirect_to "/"
    end
  end
end

for some reason gives me:

NoMethodError - undefined method `redirect_to'

UPD: while using redirect to "/" redirects me to /, not /lab/.

Nakilon commented Nov 28, 2016

This

namespace "/lab" do
  namespace "/dpap" do
    get "" do
      redirect_to "/"
    end
  end
end

for some reason gives me:

NoMethodError - undefined method `redirect_to'

UPD: while using redirect to "/" redirects me to /, not /lab/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment