我创建了一条路线:
user_currency GET /user/currency/:currency(.:format) user#currency
这是我的用户控制器:
class UsersController < ApplicationController
require 'will_paginate/array'
require 'gdata'
before_filter :ensure_user_friendly_url, :only => [:show, :following, :followers, :friends, :designers]
before_filter :check_if_signed_in, :only => :signup
路线的控制器:
def currency
session[:currency] = params[:currency]
redirect_to :back
end
我收到错误:
uninitialized constant UserController
此处发生错误:
- currency_values.each do |currency|
%li
= link_to "#{currency.country}", user_currency_url(currency.id)
我将currency_id
作为货币传递。
答案 0 :(得分:2)
在您的路线声明中,您错误地引用了控制器名称。它应该是:
user_currency GET /user/currency/:currency(.:format) users#currency
基本上您的控制器为UsersController
而不是UserController
。