views:

36

answers:

1

Hi i have this starnge behavoir...

<%= link_to image_tag("image.png"), brain_path(1), :method => "put" %>

produces:

<a href="/brain.1" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.met ...[many rails code]... ;return false;"><img alt="Research_4" src="/images/image.png" /></a>

a href="/foobar.1" this is the strange part :( any ideas whqt is causing this?

rake routes gives the following:

new_brain GET /brain/new(.:format) {:controller=>"brains", :action=>"new"}

   edit_brain GET    /brain/edit(.:format)              {:controller=>"brains", :action=>"edit"}
        brain GET    /brain(.:format)                   {:controller=>"brains", :action=>"show"}
              PUT    /brain(.:format)                   {:controller=>"brains", :action=>"update"}
              DELETE /brain(.:format)                   {:controller=>"brains", :action=>"destroy"}
              POST   /brain(.:format)                   {:controller=>"brains", :action=>"create"}
A: 
  1. How do you route your foobar? (singular or plural? resource or resources?)

  2. Are you sure that you're using foobar_path(1), not foobars_path(1) (singular form)

in real life foobars_path(1) will return /foobars.1 and foobar_path(1) - /foobar/1

as I see you have to use brain_path(1) not brain_path(1)

UPD

Change your route.rb

map.resources :brain

it will be better if you'll rename your controller into pluralize brains - it is more conventional when you are using resources

fl00r
hi thanks for your replyin routes.rb i use map.resource :brainyes i'm sure that i use brain_path(1)
Dominik
Change `map.resource :brain` to `map.resources :brain` (note the plural) and then it will work. If you don't want/need the index action you can do `map.resources :brain, :except => [:index]`
rspeicher
rspeicher is right, you can't use brain/1 (brain_path(1)) because you've got ONLY ONE BRAIN when you route brain as a RESOURCE (singular!). As you can see in rake:routes you haven't got /brain/:id resource. So, you need to change your route.rb to __map.resources :brain__
fl00r