Possible bug: edge rails, nested resources and images

Im trying to show images in my restful application and have finally
found what appears to be the source of the problem.

When i have the products resource nested in categories as showen below
in the first routes file i can see the categories index (/categories).

When i add the images to the products resource map as shown in routes 2
i get the error:

image_url failed to generate from {:controller=>“images”,
:action=>“show”, :category_id=>“rails”}

It appears that the image_tag is being confused for an image_url ???

Has anyone come across this or have the acts_as_attachment plugin
working in their application.

  1. routes.rb (working version1) =========================
    #eg categories/1/products

map.resources :categories do |categories|
categories.resources :products
end

map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’
map.connect ‘:controller/:action/:id’

  1. routes.rb (not working version2)=============================
    #eg categories/1/products/1/images

map.resources :categories do |categories|
categories.resources :products do |products|
products.resources :images
end
end

map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’
map.connect ‘:controller/:action/:id’

view/index==============================
<%= image_tag ‘rails’ %>

error ==================================
ActionController::RoutingError in Categories#index
Showing app/views/categories/index.rhtml where line #20 raised:

image_url failed to generate from {:controller=>“images”,
:action=>“show”, :category_id=>“rails”}, expected:
{:controller=>“images”, :action=>“show”}, diff: {:category_id=>“rails”}

I just changed the nested loop to look like this:

#resource mappings
map.resources :categories do |categories|
categories.resources :products do |products|
products.resources :parts
end
end

This now works. Parts is inherited from images.

So, it looks like you can’t have a resource called images! As this will
cause the image_tag to be read as image_url.

It would be good to get someones opinion on this, jsut in case im waaay
of base.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs