Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Path/URL helpers broken for BigDecimal ID

#2643

I'm running a generated tutorial Rails (2.3.2) application on JRuby (1.2.0) against the Oracle 10 database connection via JDBC adapter (0.9.1). The ID column is represented as BigDecimal. None of the pat/URL shortcut helpers (path, edit_path etc.) is working in the templates.

Template has a link:

<%= link_to "Show", book %>

It gives the runtime error:

book_url failed to generate from {:controller=>"books", :action=>"show", :id=>#, title: "Just In Case", author: "Mike Trenton">}, expected: {:controller=>"books", :action=>"show"}, diff: {:id=>#, title: "Just In Case", author: "Mike Trenton">}

Using the full specified link_to with :controller, :action and :id works as far as the BigDecimal ID is converted via to_int.

Note that other functions are affected as well if they rely on teh helpers - like form_for, which I did not find a workaround yet.

Reported by Ales Bukovsky · May 13th, 2009 @ 08:17 PM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Ales Bukovsky
    Ales Bukovsky

    There is apparently a problem in the JDBC adapter (0.9.1) implementation for Oracle.

    http://www.ruby-forum.com/topic/180358

    As result, the integer column is mapped in the Ruby code as a BigDecimal. With the workaround mentioned in the linked post, the ID is mapped properly as an integer and all problems I've described disappear. I’m not sure why Rails chokes on BigDecimal IDs but I can understand that integer is required. However, the linked discussion also indicates that the URL/path generation worked with Rails 2.2.2 although the ID originating in teh BigDecimal was created as X.X. So there still could be a problem in the Rails URL generation code when BigDecimal ID is given, because in 2.3.2 it just dies with an error.

    May 14th, 2009 @ 02:50 PM

  2. Ales Bukovsky
    Ales Bukovsky

    The typecast issue is now cross-reported in the ActiveRecord JDBC adapter bug tracker as well:

    http://kenai.com/jira/browse/ACTIVERECORD_JDBC-17

    May 14th, 2009 @ 04:33 PM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:35 PM

  5. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:35 PM