Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.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 文章中的LoadError#索引无法加载这样的文件——RubyonRails中用于twitter身份验证的omniauth_Ruby On Rails_Ruby_Twitter_Omniauth - Fatal编程技术网

Ruby on rails 文章中的LoadError#索引无法加载这样的文件——RubyonRails中用于twitter身份验证的omniauth

Ruby on rails 文章中的LoadError#索引无法加载这样的文件——RubyonRails中用于twitter身份验证的omniauth,ruby-on-rails,ruby,twitter,omniauth,Ruby On Rails,Ruby,Twitter,Omniauth,我正在尝试对我的博客进行twitter身份验证。我已经在我的应用程序中实现了Desive。所以我遵循http://railscasts.com/episodes/235-devise-and-omniauth-revised视频。当我完成本视频中提到的所有步骤并尝试访问我的应用程序时,我发现无法加载这样的文件--omniauth错误。错误消息的详细信息如下 Extracted source (around line #12): 9: <div id="tabs"> 10:

我正在尝试对我的博客进行twitter身份验证。我已经在我的应用程序中实现了Desive。所以我遵循
http://railscasts.com/episodes/235-devise-and-omniauth-revised
视频。当我完成本视频中提到的所有步骤并尝试访问我的应用程序时,我发现
无法加载这样的文件--omniauth
错误。错误消息的详细信息如下

Extracted source (around line #12):

9:   <div id="tabs"> 
10:   <ul id="tabs">
11:     <li><div style="color:#82b548;font-size: 0.9em;">  <%= time_tag(article.created_at.in_time_zone("Asia/Calcutta")) %> </div></li>
12:     <li> <div style="color:#4895d1; font-size: 0.9em;">  <%= article.user.username if article.user %></div></li>
13:     <% if !article.nil? %>
14:       <li><div style="color:#CCD600; font-size: 0.9em;">  <%= article.comments.size %> comments </div></li>
15:       <li><div style="color:#CCD600; font-size: 0.9em;"> <%= link_to article.tags.collect(&:name).join(" ") %> </div></li>
Rails.root: f:/kuta/billi

Application Trace | Framework Trace | Full Trace
app/models/user.rb:15:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
app/views/articles/index.html.erb:12:in `block in _app_views_articles_index_html_erb__265352894_31994844'
app/views/articles/index.html.erb:6:in `each'
app/views/articles/index.html.erb:6:in `_app_views_articles_index_html_erb__265352894_31994844'
提取的源代码(第12行附近):
9:    
10:
    11:
  • 12:
  • 13: 14:
  • 评论
  • 15:
  • Rails.root:f:/kuta/billi 应用程序跟踪|框架跟踪|完整跟踪 app/models/user.rb:15:in`' app/models/user.rb:1:in`' app/views/articles/index.html.erb:12:in'block in_app_views_articles_index_html_erb_265352894_31994844' app/views/articles/index.html.erb:6:in'each' app/views/articles/index.html.erb:6:in`_app_views_articles_index_html_erb_265352894_31994844'
型号/用户.rb

class User < ActiveRecord::Base
  attr_accessible :username, :email, :password, :password_confirmation, :remember_me
  attr_accessible :title, :body
  validates_confirmation_of :password
  validates_presence_of :password, :on => :create
  validates_presence_of :email, :on => :create
  validates_presence_of :username, :on => :create
  validates_uniqueness_of :email
  validates_uniqueness_of :username
    has_many :articles, :order => "created_at DESC"
    has_many :comments
  # Include default devise modules. Others available are:
  # :token_authenticatable, 
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :omniauthable,
   :recoverable, :rememberable, :trackable, :validatable

  def self.from_omniauth(auth)
   where(auth.slice(:provider, :uid)).first_or_create do |user|
    user.provider = auth.provider
    user.uid = auth.uid
    user.username = auth.info.nickname
    end
  end

  def self.new_with_session(params, session)
    if session["devise.user_attritubes"]
      new(session["devise.user_attributes"], without_protection: true) do |user|
      user.attributes = params
      user.valid?
      end
    else
     super
    end
  end

  def password_required?
   super && provider.blank?
  end

end
class用户:create
验证是否存在:电子邮件,:on=>:创建
验证是否存在:username,:on=>:create
验证电子邮件的唯一性
验证用户名的唯一性
有多篇:文章,:order=>“在DESC创建”
有很多评论
#包括默认设计模块。其他可供选择的项目包括:
#:令牌可验证,
#:可锁定,:可超时和:可全授权
设计:数据库可认证,:可注册,:全可认证,
:可恢复,:可记忆,:可跟踪,:可验证
定义自授权(授权)
其中(auth.slice(:provider,:uid)).first_或_create do|user|
user.provider=auth.provider
user.uid=auth.uid
user.username=auth.info.昵称
结束
结束
定义self.new_与_会话(参数,会话)
如果会话[“设计用户属性”]
新建(会话[“Desive.user_attributes”],无_保护:true)do|user|
user.attributes=params
user.valid?
结束
其他的
超级的
结束
结束
是否需要def密码?
super&&provider.blank?
结束
结束

我认为错误在于我的代码的12行,它是关于用户的。但我确实不知道我错过了什么。如果需要粘贴更多代码,请告诉我。谢谢

请发布你的
应用程序/模型/用户.rb
嗨,孩子们,我已经用user.rb更新了问题。感谢您的回复。您已经在您的
Gemfile
中正确添加并捆绑了
omniauth twitter
gem,对吗?嗨,孩子们,是的。这里是:gem“omniauth”、“~>1.1.1”gem“omniauth twitter”、“~>0.0.14”hi Kiddorails,当我从user.rb模型中删除omniauthable时,它以某种方式工作。我们真的需要user.rb中的omniauthable吗。但它并不完全有效。