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 6102813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:39:28+00:00 2026-05-23T13:39:28+00:00

With rails version 2.3.8 I’m trying to get HTML output like: <a href=/product/list data-role=button>Product

  • 0

With rails version 2.3.8 I’m trying to get HTML output like:

    <a href="/product/list" data-role="button">Product list</a>

So an A tag with a custom attribute “data-role”. (The reason I want the “data-role” attribute is that I’m working with JQuery Mobile which picks up on this attribute and does its magic) So I was trying to do this

    <%= link_to "product list", :controller => "product", :action => "list", "data-role" => "button" %>

Judging by this tutorial perhaps this would work in rails 3, but in rails 2.3.8 it interprets it by generating a data-role=button parameter on the link URL.

One way I can get the desired HTML output is to use url_for instead:

    <a href="<%=url_for :controller =>"product", :action => "list" %>" data-role="button">Product list</a> 

A bit long and ugly. Is there a way to make link_to output custom attributes in the A tag (?)

  • 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-23T13:39:28+00:00Added an answer on May 23, 2026 at 1:39 pm

    Try

    <%= link_to "product list", { :controller => "product", :action => "list" }, "data-role" => "button" %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run http://github.com/tardate/rails-authlogic-rpx-sample (only rails version was changed) but get error message
I'm trying to get a Ruby on Rails project started on Dreamhost, ruby version
I'm trying to get a Rails (version 2.3.5) app set up to run RSpec
I am new to rails. My rails version is 2.3.5. I found usage like:
I'm running rails version 2.3.5 and rubygems version 1.3.6, when I script/server I get
What would be the best way to version a rails application? We want to
I'm working with an older version of Rails and ActiveRecord that does not have
I want to use the last version of rails, in my Gemfile: gem 'rails',
Experienced with Rails / ActiveRecord 2.1.1 You create a first version with (for example)
Especially when considering a fresh Rails project, what does your version control and deployment

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.