2
我在顯示來自單獨控制器的數據時出現問題。我有許多用戶,每個用戶都有很多頁面。我已經按照this教程進行了一些小調整。NoMethodError - undefined方法
是不斷出現的錯誤是:
NoMethodError in SitesController#show
undefined method `page' for #<ActionDispatch::Request:0x00000102452d30>
我的routes.rb如下:
devise_for :users
resources :users, :only => [:index, :show] do
resources :pages, :shallow => true
end
match '/' => 'sites#show', :constraints => { :subdomain => /.+/ }
root :to => "home#index"
而且我有一個站點控制器:
class SitesController < ApplicationController
def show
@site = Site.find_by_name!(request.page)
end
end
我已經還嘗試過:
def show
@site = Site.find_by_name!(params[:site])
end
這給出了不同的錯誤。
我總是試圖弄清楚這一點!
期待您的協助。
鮑勃