0

我试图重定向用户show_city_urlshow_city_path但我得到一个异常,他们都是undefined。在城市控制器我有三个动作显示,喜欢和不喜欢。 unlike_city_pathlike_city_path作品,但show_city_path doesnt.Also当我把这个在all_cities行动redirect_to :controller=>"city",:action=>"show"作品。我做错了什么?谢谢。足智多谋的助手_path和_url不工作

class HomeController < ApplicationController 

    def all-cities 
     redirect_to show_city_url 
    end 

    end 

在路线

 resources :city do 
    member do 
    post :like 
    post :dislike 
    get :show 
    end 
    end 

回答

1

根据您的意见:

resources :cities, :controller => 'city' do 
    collection do 
    get :show, :as => :show 
    end 

    member do 
    post :like 
    post :dislike 
    end 
end 

现在你可以打电话show_cities_url,你会在你的CityController的表演动作着陆。

PS:继Rails的惯例,使您的生活更轻松;)

回报率指南:Rails Routing from the Outside In

+0

现在它告诉我未初始化的常量CitiesController – katie

+0

什么是你的控制器的显示/列出了城市的名字吗? – sled

+0

它是CityController – katie

相关问题