0

Weird error. I'm a newby to rails. From a new install of rails I connected to an oracle db and then ran:

jruby script/generate scaffold job oid:integer userid:integer name:string status:integer

Without doing anything else I started up the server and entered a new job and then I get this error:

Routing Error

job_url failed to generate from {:controller=>"jobs", :action=>"show", :id=>#<Job id: #<BigDecimal:d55a0f,'10000.0',1(8)>, oid: #<BigDecimal:10bb83e,'1324.0',4(8)>, userid: #<BigDecimal:6d234c,'1234.0',4(8)>, name: "asdfadsf", status: #<BigDecimal:1286c71,'1234.0',4(8)>, created_at: "2009-12-15 00:49:37", updated_at: "2009-12-15 00:49:37">}, expected: {:controller=>"jobs", :action=>"show"}, diff: {:id=>#<Job id: #<BigDecimal:853e51,'10000.0',1(8)>, oid: #<BigDecimal:1be4050,'1324.0',4(8)>, userid: #<BigDecimal:adb165,'1234.0',4(8)>, name: "asdfadsf", status: #<BigDecimal:15978e7,'1234.0',4(8)>, created_at: "2009-12-15 00:49:37", updated_at: "2009-12-15 00:49:37">}

Even though it throws the error it still creates the record. When I try to view the record I get the following stack, which is really the same error.

ActionController::RoutingError in Jobs#show

Showing app/views/jobs/show.html.erb where line #22 raised:

edit_job_url failed to generate from {:controller=>"jobs", :action=>"edit", :id=>#<Job id: #<BigDecimal:18caa36,'10000.0',1(8)>, oid: #<BigDecimal:1fac733,'1324.0',4(8)>, userid: #<BigDecimal:12c1472,'1234.0',4(8)>, name: "asdfadsf", status: #<BigDecimal:f25f89,'1234.0',4(8)>, created_at: "2009-12-15 00:49:37", updated_at: "2009-12-15 00:49:37">}, expected: {:controller=>"jobs", :action=>"edit"}, diff: {:id=>#<Job id: #<BigDecimal:1b9cdfc,'10000.0',1(8)>, oid: #<BigDecimal:1829097,'1324.0',4(8)>, userid: #<BigDecimal:e2d663,'1234.0',4(8)>, name: "asdfadsf", status: #<BigDecimal:691ccf,'1234.0',4(8)>, created_at: "2009-12-15 00:49:37", updated_at: "2009-12-15 00:49:37">}
Extracted source (around line #22):

19: </p>
20: 
21: 
22: <%= link_to 'Edit', edit_job_path(@job) %> |
23: <%= link_to 'Back', jobs_path %>
RAILS_ROOT: /opt/code/import

Application Trace | Framework Trace | Full Trace
/opt/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:426:in `raise_named_route_error'
/opt/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:387:in `generate'
/opt/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/url_rewriter.rb:205:in `rewrite_path'
/opt/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/url_rewriter.rb:184:in `rewrite_url'
/opt/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/url_rewriter.rb:162:in `rewrite'
/opt/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:634:in `url_for'
/opt/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/url_helper.rb:85:in `url_for'
(eval):16:in `edit_job_path'
/opt/code/import/app/views/jobs/show.html.erb:22:in `_run_erb_app47views47jobs47show46html46erb'
/opt/code/import/app/controllers/jobs_controller.rb:18:in `show'
Request

Parameters:

{"id"=>"10000"}
Show session dump

Response

Headers:

{"Cache-Control"=>"no-cache",
 "Content-Type"=>"text/html"} 

When I remove the "edit_job_path" method the error disappears so I know it's just having an issue rendering the route, but I'm not sure why because it seems to have the correct info. I mean this is a boilerplate scaffold so.... Thanks in advance for any help!

2 Answers 2

2

This is because your ID field is a BigDecimal, where it should be an Integer. It is interpreting a number such as "1234.54" separated into two parts, something like {:action => "1234", :format => "54" }.

Sign up to request clarification or add additional context in comments.

1 Comment

Bingo. Thanks Ryan! I realized there was something going on with that BigDecimal after I posted it, but wasn't exactly sure what. You nailed it. This was happing because I was using JRuby, which I don't need to do, so I'm switching back to a non-Java Ruby VM.
1

Make sure you have this line in your config/routes.rb:

map.resources :jobs

Also run "rake routes" to see what routes are available. The *path and *url methods are generated by named routes and resources you define in the routes.rb file. More info here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.