2016-05-27 7 views
0

私はここに同じ問題がありますundefined local variable or method `resource_class' in devise。問題は、コードがすでに回答のように設定されていることです。それはルートの問題ですか?私は他の場所を見るべきでしょうか?エラー "未定義のローカル変数またはメソッド" resource_class ""

class ApplicationController < ActionController::Base 

    protect_from_forgery with: :exception 

    before_action :set_locale 
    before_action :set_instances 
    before_action :configure_permitted_parameters, if: :devise_controller? 
    before_action :mixpanel 

    def set_locale 
    I18n.locale = params[:locale] || I18n.default_locale 
    end 

    def redirect_to_back 
    begin 
    redirect_to :back 
    rescue ActionController::RedirectBackError => e 
    redirect_to root_path 
    end 
    end 

    def set_instances 
    @new_event ||= Event.new(title: ".......", capacity: 50, start_date: Time.zone.now, start_time: Time.zone.now, end_time: Time.zone.now) 
    @featured_quizz ||= Questionnaire.where('featured IS TRUE') 
    end 

    helper_method :resource_name, :resource, :devise_mapping 

    protected 


    def resource_name 
    :user 
    end 

    def resource 
    @resource ||= User.new 
    end 

    def devise_mapping 
    @devise_mapping ||= Devise.mappings[:user] 
    end 

    def configure_permitted_parameters 
    devise_parameter_sanitizer.for(:sign_up) << [:name, :firstname, :lastname, :phone] 
    devise_parameter_sanitizer.for(:account_update) << [:name, :firstname, :lastname, :image, :phone] 
    end 

end 

#<#のため=> _links.html.slim

.row.text-center 
.col-md-10.col-md-offset-1 

    - if devise_mapping.omniauthable? 
    - resource_class.omniauth_providers.each do |provider| 
     = link_to omniauth_authorize_path(resource_name, provider), class:"btn btn-fb btn-block callout callout-fb" 
     span.fa.fa-facebook-official<> 
     span Connectez vous aveC#{provider.to_s.titleize} 

未定義のメソッド `users_path」:それは前に構文エラー0x007ff25695fce0>

ですか? Devise Readmeは何も言及していない:私はこの問題は、関連する工夫だとは思わないあなたの助け

+2

"bundle exec rake routes"と入力し、上記の出力を送信してください。 – bkunzi01

+0

私はそれを試してみました。 36000人以上のキャラクター新しい質問でもそれを広告することはできません –

答えて

0

のための私のroutes.rbを=>

devise_for :users, :controllers => { 
    :registrations => "registrations", 
    :sessions => "sessions", 
    :confirmations => "confirmations", 
    :omniauth_callbacks => "callbacks" } 
devise_for :admins 

おかげで

li = link_to "Votre Compte", resource, as: resource_name, url: session_path(resource_name), remote: true, data: { toggle: "modal", target: "#login-modal" } 

またはそれがブロックされdevise_for

users_pathusers_pathヘルパーメソッドで使用されているモデルのルートを作成するには、config/routes.rb行を使用します。

get '/users', to: 'users#index', as: :users 

またはまもなく、あなたはおそらくより多くのルートが必要になりますので、:

resources :users, only: [:index] # you can skip the :only parameter if you need all restful routes. 

チェックRails Routing from the Outside In詳細については。

+0

リソース:users、 'users#index'には、:ユーザーとリソース:usersのみ:[:index] ==>私に "未定義のローカル変数またはメソッド" #<#:0x007fcaf06e76d0> "の_links.html.slimのブロックを持つresource_classは –

+0

以上です。問題はresource_classにあるようです。助けてください、3日間私は試しています:( –

+0

あなただけの行の1つを追加して(レールは 'resources:users'です)、それをさらに調べてみるつもりです。 'link_to:user'のようなものを使用してください – floum

関連する問題