Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 未初始化的常量ActiveSupport::Memorizable_Ruby On Rails_Ruby_Facebook - Fatal编程技术网

Ruby on rails 未初始化的常量ActiveSupport::Memorizable

Ruby on rails 未初始化的常量ActiveSupport::Memorizable,ruby-on-rails,ruby,facebook,Ruby On Rails,Ruby,Facebook,我一直在努力让fb_图工作,这样我就可以得到一些东西,比如某人的朋友列表,但我无法摆脱这个错误。ActiveSupport::Memorizable包含在facebook类中。尝试从这里的fb_图形示例应用程序中找出它 错误图像: facebook模式: 类Facebook

我一直在努力让fb_图工作,这样我就可以得到一些东西,比如某人的朋友列表,但我无法摆脱这个错误。ActiveSupport::Memorizable包含在facebook类中。尝试从这里的fb_图形示例应用程序中找出它

错误图像:

facebook模式: 类Facebook
      def profile
        @profile ||= FbGraph::User.me(self.access_token).fetch
      end

      class << self
    extend ActiveSupport::Memoizable

    def config
      @config ||= if ENV['fb_client_id'] && ENV['fb_client_secret'] && ENV['fb_scope']
        {
          :client_id     => ENV['fb_client_id'],
          :client_secret => ENV['fb_client_secret'],
          :scope         => ENV['fb_scope'],

        }
      else
        YAML.load_file("#{Rails.root}/config/facebook.yml")[Rails.env].symbolize_keys
      end
    rescue Errno::ENOENT => e
      raise StandardError.new("config/facebook.yml could not be loaded.")
    end

    def app
      FbGraph::Application.new config[:client_id], :secret => config[:client_secret]
    end

    def auth(redirect_uri = nil)
      FbGraph::Auth.new config[:client_id], config[:client_secret], :redirect_uri =>     redirect_uri
    end

    def identify(fb_user)
      _fb_user_ = find_or_initialize_by_identifier(fb_user.identifier.try(:to_s))
      _fb_user_.access_token = fb_user.access_token.access_token
      _fb_user_.save!
      _fb_user_
    end
  end    
end
这是facebooks\u控制器

require 'rack/oauth2'
class FacebooksController < ApplicationController
  before_filter :require_authentication, :only => :destroy

  rescue_from Rack:.center.hero-unit
  %h1 Welcome to Dropshare
  %h2
    This is the home page for Dropshare
  %p (at least for time being)
  = render 'layouts/facebook_signup' 
  = render 'layouts/drive_signup'
/
  <haml:loud> provide(:title, &amp;#39;Home&amp;#39;)</haml:loud>
  <h1>Home</h1>
  <p>This is the home page (for the time being) for Dropshare</p>
  <a href="/signup" class="btn btn-large btn-primary">Sign up now!</a>
:OAuth2::Client::Error, :with => :oauth2_error

  # handle Facebook Auth Cookie generated by JavaScript SDK
  def show
    auth = Facebook.auth.from_cookie(cookies)
    authenticate Facebook.identify(auth.user)
    redirect_to dashboard_url
  end

  # handle Normal OAuth flow: start
  def new
    client = Facebook.auth(callback_facebook_url).client
    redirect_to client.authorization_uri(
      :scope => Facebook.config[:scope]
    )
  end

  # handle Normal OAuth flow: callback
  def create
    client = Facebook.auth(callback_facebook_url).client
    client.authorization_code = params[:code]
    access_token = client.access_token! :client_auth_body
    user = FbGraph::User.me(access_token).fetch
    authenticate Facebook.identify(user)
    redirect_to dashboard_url
  end

  def destroy
    unauthenticate
    redirect_to root_url
  end

  private
  def oauth2_error(e)
    flash[:error] = {
      :title => e.response[:error][:type],
      :message => e.response[:error][:message]
    }
    redirect_to root_url
  end
end
解决方案 代替 ActiveSupport::可记忆
使用memoist和require'memoist'

我想您可能会遇到这样一个事实:ActiveSupport::Memorizable已被弃用并从Rails中删除。

该gem的作者在其gemfile中运行此版本的Rails,因此我认为它通过以下方式得到支持:

gem 'rails', '~>3.2.11'
我猜您运行的是更新版本的Rails