Inconsistent routing

Hi list,

I’m getting some weird routing issues.
My extension defines two routes to send requests to a new controller.
It looks like these routes are only recognized about half of the time
(at random).
The other times the url is just sent to the site_controller for ‘normal’
processing.

I guess this means that my laptop is too slow half of the time, and that
the extra routes are not set fast enough…?

It doesn’t seem to matter if i move the extension to the front or the
end of the extension load_order.

Anybody have a clue of what could cause or even better fix this?

Thanks in advance,

Benny

Benny,

Would you paste us the route definitions?

Sean

;
define_routes do |map|
map.connect “en/shop/:action/:id”, :controller => ‘shop’, :language
=> ‘en-US’
map.connect “nl/shop/:action/:id”, :controller => ‘shop’, :language
=> ‘nl-BE’
end

Sean C. wrote:

Benny,

Would you paste us the route definitions?

Sean

Benny,

Try this:

define_routes do |map|
map.with_options :controller => ‘shop’, :action => ‘index’ do |shop|
shop.connect “en/shop/:action/:id”, :language => ‘en-US’
shop.connect “nl/shop/:action/:id”, :language => ‘nl-BE’
end
end

My guess is that without the “default” action of ‘index’, it doesn’t
match. You can test these in a functional test:

def test_shop_routing_with_language
assert_recognizes “/en/shop”, :controller => “shop”, :action =>
“index”, :language => ‘en-US’
assert_recognizes “/nl/shop”, :controller => “shop”, :action =>
“index”, :language => ‘nl-BE’

etc…

end

Sean

Nope, i’m still getting the same results; sometimes works, sometimes
doesn’t.

the assert_recognizes didn’t seem to work that way, i had to switch the
first part (’/en/shop’) and the options to get those to pass

Sean C. wrote:

Benny,

Try this:

define_routes do |map|
map.with_options :controller => ‘shop’, :action => ‘index’ do |shop|
shop.connect “en/shop/:action/:id”, :language => ‘en-US’
shop.connect “nl/shop/:action/:id”, :language => ‘nl-BE’
end
end

Benny,

Ah, sorry. You might try assert_routing, which does both a generation
and a recognition assertion. Now, I don’t know if it has anything to do
with your problem, but I have found that it’s more reliable to use named
or resource routes in extensions. I’m not sure if this is a Radiant
issue or a Rails issue. Try naming those and see if it becomes more
consistent.

Sean

I’m getting some weird routing issues.
My extension defines two routes to send requests to a new controller.
It looks like these routes are only recognized about half of the time
(at random).
The other times the url is just sent to the site_controller
for ‘normal’
processing.

Do you have multiple mongrel/fcgi processes? Is it possible that you
haven’t restarted both of them? (and hence one may not have
read your code).

Are you using trunk or a previous version? This bug may have been
introduced in the extension-loading refactoring.

Sean

assert_routing works indeed. The test passes, but i’m still getting the
same results:

app.get(’/en/shop’)
=> 302

app.get(’/en/shop’)
=> 200

app.get(’/en/shop’)
=> 302

app.get(’/en/shop’)
=> 200

app.get(’/en/shop’)
=> 302

app.get(’/en/shop’)
=> 200

app.get(’/en/shop’)
=> 200

app.get(’/en/shop’)
=> 200

This is with a named route.

Daniel; as far as i know i’m not working with multiple mongrel
processes. I’m still working in development mode only, and i haven’t
played with setting up mongrel clusters or anything…

Ah. Try freezing to revision 679:

rake radiant:freeze:edge REVISION=679

Sean

Hey all,

I’m building a rake task to pull all my data from my production db
(MySql) to my development db (SQLite). It works great pulling in that
direction, but when I go to reverse the process, it fails. It has to
do with my plugin that uses attachment_fu.

Basically, I have a model Asset that uses ‘has_attachment’. This is
the code that doesn’t work:

“asset”.classify.constantize

This is the error:
NoMethodError: undefined method `has_attachment’ for Asset:Class

Any ideas what the difference is between production and development
that would cause this to not work? I can run the server in dev mode,
I just can’t run constantize. This error does not happen in the
production environment. I’ve tried changing the contents of config/
environments/development.rb with no success.

Thanks!

-Chris

Sean C. wrote:

Are you using trunk or a previous version? This bug may have been
introduced in the extension-loading refactoring.

Sean

I’m on 0.6.4, running from gem

Sean C. wrote:

Ah. Try freezing to revision 679:

rake radiant:freeze:edge REVISION=679

Sean

freezing didn’t solve the problem, but i’ve found out more about it…
Turning off another extension, i noticed that i had good results more
often.
I then tried the extension on the production server, and it all works
flawless there…
maybe it’s time for a reboot… :slight_smile:

Nevermind, I must have had something wacky in my config. I started
fresh with a new 0.6.4 install and brought in my extension, and it
seems fine now. Sorry for the noise on the channel…

-C