I have a link_to
method in Rails
link_to("feedback", meetings_url(:anchor => "sometext"))
=> The above code produces:
<a href="/p/meeting/?scroll_to=sometext">feedback</a>
I thought anchor was supposed to prepend a hash paramter, something like this:
/p/meeting/#sometext
Rails is able to map any object that you pass into link_to by its model. It actually has nothing to do with the view that you use it in. It knows that an instance of the Profile class should map to the /profiles/:id path when generating a URL.
In computing, a hyperlink, or simply a link, is a reference to data that the user can follow by clicking or tapping. A hyperlink points to a whole document or to a specific element within a document. Hypertext is text with hyperlinks.
open index. html. erb file in app>>views>>home folder use in atom editor. After you open index file now add following HTML link code in that file and end with <br /> tag.
The rails link_to is a helper which helps us in creating a hyperlink to the existing main document. The Rain link_to will be created as anchor tag or the h-ref tag. Anchor tag is known as an HTML code that creates another link to another page or to a specific section of the existing document.
I just tried in the console and I get the expected #anchor
include Rails.application.routes.url_helpers # => Object default_url_options[:host] = "localhost" # => "localhost" profiles_url(:anchor => "moo") # => "http://localhost/profiles#moo"
What version of rails are you using? Do yo maybe have a gem or plugin that is overriding your link_to helper? You could create an empty rails app, and try the above test to see if something else is causing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With