为了清理我的代码,我想访问Rails模型中的RESTful帮助器。就像是:
users_path
等等。
谢谢。
最佳答案
class ActiveRecord::Base
include ActionController::UrlWriter
host = case ENV['RAILS_ENV']
when "production"
"yourlivedomain.com"
when "development"
"localhost:3000"
end
default_url_options[:host] = host
end