Search code examples
ruby-on-railsrubyhaml

Rails's link_to return url with dot instead of slash


Rails 3.0.9 with haml gem & Ruby 1.9.2-head with rvm

I have order resource.

Fragment of routes.rb file

resources :orders

The call link_to helper with instance of the Order model return /order.2 instead of /orders/2.

Fragment of order_controller.rb and index.html.haml

#index.haml.html
%ul
  - @orders.each do |item|
    %li= link_to item.id, item #=> <a href="/order.2">2</a> instead of  <a href="/orders/2">2</a>

#orders_controller.rb 
def index 
  @orders = Order.all
 end

What I do wrong?

I also have another resources but they work fine.

Update:

Listing of my routes.rb file

  YetApp::Application.routes.draw do

  resources :categories, :products, :images, :orders, :small_images

  match "/order", :to => "orders#new", :as=> 'order'

  match "/success/:id", :to => "orders#success", :as=> 'order'

  #namespace :signed do
  #  resources :products, :images, :categories
  #end

  root :to => 'pages#home'

  match '/signed', :to => 'pages#signed', :as => 'signed'


  match '/cooperation', :to => 'pages#cooperation', :as => 'cooperation'
  match '/payment', :to => 'pages#payment', :as => 'payment'
  match '/offer', :to => 'pages#offer', :as => 'offer'
  match '/order', :to => 'pages#order', :as => 'order'

end

Solution

  • I think you should remove the

    match '/order', :to => ...
    

    from your routes file.