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 HTML anchor option to `url` #1671

Closed
daddz opened this Issue May 2, 2014 · 5 comments

Comments

Projects
None yet
3 participants
@daddz

daddz commented May 2, 2014

It would be nice to add an option to the url function so you can redirect to a specific HTML anchor.

Something like url(:foo, :bar, :anchor => :foobar) which would generate /foo/bar#foobar

Or did I just miss something in the documentation?

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc May 2, 2014

Member

There's :anchor option for #link_to method. Is there a reason to add it for #url method?

Member

ujifgc commented May 2, 2014

There's :anchor option for #link_to method. Is there a reason to add it for #url method?

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka May 2, 2014

Member

For example, the src attribute of the iframe element can contain an anchor.
I think the suggestion is reasonable.

Member

namusyaka commented May 2, 2014

For example, the src attribute of the iframe element can contain an anchor.
I think the suggestion is reasonable.

@daddz

This comment has been minimized.

Show comment
Hide comment
@daddz

daddz May 2, 2014

@ujifgc, but I can't redirect with #link_to

I would use it like this: redirect url(:foo, :bar, :anchor => :foobar)

daddz commented May 2, 2014

@ujifgc, but I can't redirect with #link_to

I would use it like this: redirect url(:foo, :bar, :anchor => :foobar)

@daddz

This comment has been minimized.

Show comment
Hide comment
@daddz

daddz May 2, 2014

Or a more explicit example:

post :create do 
  foobar = Foobar.new(params[:foobar])
  if foobar.save
    redirect url(:foo, :list, :anchor => foobar.id)
  end
  #etc..etc
end

daddz commented May 2, 2014

Or a more explicit example:

post :create do 
  foobar = Foobar.new(params[:foobar])
  if foobar.save
    redirect url(:foo, :list, :anchor => foobar.id)
  end
  #etc..etc
end
@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc May 3, 2014

Member

Makes sense. We should deprecate :anchor option in #link_to.

Member

ujifgc commented May 3, 2014

Makes sense. We should deprecate :anchor option in #link_to.

@namusyaka namusyaka added this to the 0.12.2 milestone May 3, 2014

@ujifgc ujifgc added the enhancement label May 3, 2014

@ujifgc ujifgc closed this in 53187aa May 5, 2014

ujifgc added a commit that referenced this issue May 5, 2014

Merge pull request #1672 from padrino/move-anchor
add options :fragment and :anchor to #url, fixes #1671
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment