Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:44:34+00:00 2026-05-23T07:44:34+00:00

In Rails 3, when utilizing the method attribute of a link_to , my custom

  • 0

In Rails 3, when utilizing the method attribute of a link_to, my custom rel value is being overwritten.

# my code:
link_to 'Add to Favorites',
  profile_favorites_path(profile),
  :method => :post,
  :class => 'button',
  :rel => 'favorite'

# expected result:
<a href="/profiles/1/favorites" class="button" data-method="post" rel="favorite nofollow">Add to Favorites</a>

# actual result:
<a href="/profiles/1/favorites" class="button" data-method="post" rel="nofollow">Add to Favorites</a>

Is this a Rails bug / unexpected feature? How can I make use of the built-in method functionality while also supplying a custom rel value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:44:35+00:00Added an answer on May 23, 2026 at 7:44 am

    Seems you can only specify the rel attribute if the method is set to get.

    Inside action_view/helpers/url_helper.rb add_method_to_attributes! you can see the logic rails is currently using for this:

    def add_method_to_attributes!(html_options, method)
      html_options["rel"] = "nofollow" if method && method.to_s.downcase != "get"
      html_options["data-method"] = method if method
    end
    

    This actually makes sense, you wouldn’t want to have bots/spiders posting when crawling links.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rails has the link_to helper, and I'm aware that its output is determined by
In rails 2.x I could pass on a --git option to ./script/generate to add
Rails 3 noob here. Currently the code in my controller below is getting the
Rails guides show the following example as a generic search form. <%= form_tag(search_path, :method
I have a Rails/ActiveRecord server utilizing Postgres via the native gem. I was wondering
Rails 2.3.5 For a link_to image_tag', I've been trying to figure out how to
Rails 2.3 has an option to add more routes anytime using RouteSet#add_configuration_file. Is it
Rails 3.1.1 , For using ajax in my application I used remote=>true method on
rails newbie here. I've started making a value based to-do list. So far I've
Rails 2.3.5 I have a report being created on 3 different views (main, pre-view,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.