Hi Guys, I have some strangeness with routing, using standard route map.connect '':controller/:action/:id'' map.connect '':controller/:action/:id.:format'' Using console I did>> rts = ActionController::Routing::Routes>> rts.generate(:action => "edit", :controller => ''vendorlocations'', :id => 10)=> "/vendorlocations/10/edit">> rts.recognize_path("/vendorlocations/10/edit")=> {:action=>"10", :id=>"edit", :controller=>"vendorlocations"} 1) I don''t understand why the ID is where the action is when I generate the router 2) And because of that the :id and :action have been switched. Has anyone seen this behaviour before? am I doing something wrong? Many Thanks Peter -- Posted via http://www.ruby-forum.com/.
I do have the same question since long..luckily you asked. I''ll watch this thread -- Posted via http://www.ruby-forum.com/.
Rails List wrote:> I do have the same question since long..luckily you asked. I''ll watch > this threadI found something which worked - if I did :controller => ''vendorlocation'' as opposed to :controller => ''vendorlocations'' it seemed to do the right thing... /vendorlocation/edit/:id Is strange though as when I use the helper edit_vendorlocation_path(location) It generates the /vendorlocations/:id/edit which is NOT accepted with a POST but it works when in a normal link.... Hmmmmm -- Posted via http://www.ruby-forum.com/.
if you edit something it should be a GET request and then POST it to the update action right? You are better off just removing the default routes and rolling your own... like map.resources :venderlocations Or is there something I''m missing here...
heimdull wrote:> if you edit something it should be a GET request and then POST it to > the update action right? You are better off just removing the default > routes and rolling your own... > > like map.resources :venderlocations > > Or is there something I''m missing here...Its a POST as I am using the remote_link_to method which seems to use a POST, I''m a total newbie at this so not sure what map.resources does (although i will now look it up) -- Posted via http://www.ruby-forum.com/.
Hey Pete, On the latest 2-3-stable I found I had to reverse the last defaults connect statements in my routing. They now read: # Rails default routes # map.connect '':controller/:action/:id.:format'' map.connect '':controller/:action/:id'' map.connect '':controller/:action'' That from this change: http://github.com/rails/rails/commit/ff643ce9679ad66a5cd79c90c096496d07d6efaf Which is in prep for Rails 3. What version of Rails are you on? -- Matthew Beale :: 607 227 0871 Resume & Portfolio @ http://madhatted.com On Thu, 2009-08-13 at 16:43 +0200, Pete Moran wrote:> Hi Guys, > > I have some strangeness with routing, using standard route > > map.connect '':controller/:action/:id'' > map.connect '':controller/:action/:id.:format'' > > Using console I did > > >> rts = ActionController::Routing::Routes > > >> rts.generate(:action => "edit", :controller => ''vendorlocations'', :id => 10) > => "/vendorlocations/10/edit" > >> rts.recognize_path("/vendorlocations/10/edit") > => {:action=>"10", :id=>"edit", :controller=>"vendorlocations"} > > 1) I don''t understand why the ID is where the action is when I generate > the router > 2) And because of that the :id and :action have been switched. > > Has anyone seen this behaviour before? am I doing something wrong? > > > > Many Thanks > > Peter
If this is a link_to_remote then its a little different. What is it that you want to happen when you click the link? If you are new to Rails I find it much easier to first get a normal link_to working then start adding ajax to the views. On Aug 13, 9:24 am, Pete Moran <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> heimdull wrote: > > if you edit something it should be a GET request and then POST it to > > the update action right? You are better off just removing the default > > routes and rolling your own... > > > like map.resources :venderlocations > > > Or is there something I''m missing here... > > Its a POST as I am using the remote_link_to method which seems to use a > POST, I''m a total newbie at this so not sure what map.resources does > (although i will now look it up) > -- > Posted viahttp://www.ruby-forum.com/.