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

The Archive Base Latest Questions

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

Is it wrong/impossible to pass a float as an id in RAILS 2.x http://mysite.com/clientversioncheck/1.1

  • 0

Is it wrong/impossible to pass a float as an id in RAILS 2.x

http://mysite.com/clientversioncheck/1.1

controller:

def clientversioncheck
  current_version = 1.1
  client_version = params[:id].to_f
  if client_version && current_version > client_version
    render :text => "update url"
  else
    render :text => "no update " + current_version.to_s + "server vs. " + client_version.to_s, :status => 404
  end
end

If I’m comparing a whole number it’s always fine but if I pass a float as a string the conversion always seems to drop the decimal portion.

So if current_version = 1.0 and I pass 1.0 in the url everything is fine
if current_version = 1.1 and I pass 1.1 in the url client_version evals as 1.0.

I thought . does not need to be escaped in URIs

If I boil things down to simply:

def clientversioncheck
  render :text => params[:id]
end

I get the truncation still

For instance: clientversioncheck/2.33 will output 2

I’ve tried the following routes:

  map.resources :api, :id => /[A-Za-z0-9\.]+?/, :format => /json|xml|plist|html/

  map.resources :api, :requirements => { :resource => /.*/ }
  • 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-30T05:25:58+00:00Added an answer on May 30, 2026 at 5:25 am

    You need to get some looser requirements into the router system as in this one:

    rails routing and params with a '.' in them

    The way to do that is to use :requirements in one way or another.

    map.resources doesn’t understand the :id option or :requirements so these two won’t work:

    map.resources :api, :id => /[A-Za-z0-9\.]+?/, :format => /json|xml|plist|html/
    map.resources :api, :requirements => { :resource => /.*/ }
    

    map.resources does take a Hash of options though so you won’t get an error when you pass it options that it doesn’t understand.

    The easiest thing to do is to define an extra route outside of map.resources that allows a dot in the :id. Something like this:

    map.resources :api
    map.connect '/apiv3/:action/:id', :controller =>'apiv3', :id => /.*/ # or whatever regex works for you
    

    Or:

    map.resources :api
    map.connect '/apiv3/:action/:id', :controller =>'apiv3', :requirements => { :id => /.*/ }
    

    You can put the map.connect before or after the map.resources.

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

Sidebar

Related Questions

Whats wrong with my buttons? here http://hiddenbrookstudio.com/index.swf , see how they rollover and dissappear
I might be searching for the wrong keywords as I find it almost impossible
Whats wrong with the following c# code? Compiler reports this error: Inconsistent accessibility: parameter
Whats wrong in below JSON Object definition I am trying to create a new
Whats wrong with this code? -(void) drawRect:(CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); if
Whats wrong with my query? ALTER TABLE test_posts ADD sticky boolean NOT NULL default
Whats wrong with this picture? Model: validates_acceptance_of :terms_of_service, :on => :create, :accept => true,
whats wrong with this? anybody help me please.. if(stripos($nerde, $hf) !== false) && (stripos($nerde,
Why is it wrong to use std::auto_ptr<> with standard containers?
If something goes wrong in a WCF REST call, such as the requested resource

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.