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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:56:35+00:00 2026-05-30T04:56:35+00:00

I’m stuck on a routing problem within a Rails 3.0.x application. What I’m trying

  • 0

I’m stuck on a routing problem within a Rails 3.0.x application.

What I’m trying to achieve is a URL like /registration/renew/1 . The idea is that this would renew registration for a member with id = 1.

So to that end I setup the following routes

routes.rb

match "registration/renew" => "registration#renew"

The user arrives at the registration page via a navigation link such as

<%= link_to "Full Member", registration_renew_path(@member)  %>

The problem is that the generated link comes out like: /registration/renew.1 which indicates that the :format extension is being created and appended. Which then I tried to make optional via inclusion of a responder argument :format as per the following matching rule

match "registration/renew(/:id(.:format))" => "registration#new"

but this fails with

No route matches {:controller=>"registration", :action=>"renew", :format=>#<Member id: 1,.....

So at this point I rechecked the Rails Guides etc but still couldn’t get to generate the URL I was after.

Only when I had the two rules:

match "registration/renew" => "registration#renew"
match "registration(/:action(/:id(.:format)))" => "registration#renew"

in the routes file would the URL /registration/renew/1 get me to the page. Although I didn’t feel that this was the correct, tidy solution.

The final question(s)

  1. What should be the link_to method
  2. What is the correct routes.rb entry

Thanks in Advance

  • 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-30T04:56:36+00:00Added an answer on May 30, 2026 at 4:56 am

    You just need pass args explicitly and define the name of this route

    match "registration(/:action(/:id(.:format)))" => "registration#renew", :as => registration_renew
    

    With only id

    <%= link_to "Full Member", registration_renew_path(:id => @member.id)  %>
    

    With id and format

    <%= link_to "Full Member", registration_renew_path(:id => @member.id, :format => :xml)  %>
    

    Without id

    <%= link_to "Full Member", registration_renew_path  %>
    

    You don’t need the route without params in your example.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.