我已经按照Railscast#235尝试建立一个最小的Facebook身份验证.
我首先建立了一个Twitter身份验证,就像Ryan本人所做的那样.这完美无瑕.
然后我继续添加Facebook登录.但是,在授权应用程序后,重定向/auth/facebook/callback失败并显示:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
Run Code Online (Sandbox Code Playgroud)
我正在使用localhost.我没有在应用程序中设置任何SSL.我究竟做错了什么?
我一直试图弄清楚Ryan Bates在他的Facebook身份验证截屏中如何设置以下"FACEBOOK_APP_ID"和"FACEBOOK_SECRET"环境变量.
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET']
Run Code Online (Sandbox Code Playgroud)
有类似的问题,但没有我能够在Rails 3.2.1上工作的答案.
更新:
截至2013年5月,我处理ENV变量的首选方法是通过费加罗宝石
ruby-on-rails environment-variables railscasts omniauth ruby-on-rails-3
我收到一个看起来像这样的错误:
undefined method `post_image_will_change!' for #<Post:0xf4e9184>
app/controllers/posts_controller.rb:43:in `new'
app/controllers/posts_controller.rb:43:in `create'
Run Code Online (Sandbox Code Playgroud)
我把它包含在我的"帖子"模型中:
attr_accessible :title, :name, :content, :post_image
mount_uploader :post_image, PostImageUploader
Run Code Online (Sandbox Code Playgroud)
并在_form.html.erb我添加了:
:html => { :multipart => true }
Run Code Online (Sandbox Code Playgroud)
我看了CarrierWave Error,但这对我没有帮助.
什么产生错误的线索?我已经迁移了数据库等等(紧跟载波的railscasts指南......)
我一直在关注ryan baytes截屏#170并将ruby-openid,authlogic和authlogic-oid添加到现有的authlogic身份验证系统中.
但是,我不断收到以下一堆错误:
NameError(未初始化的常量OpenIdAuthentication :: InvalidOpenId):/ Library/Ruby/Gems/1.8/gems/openid_identifier='
/Library/Ruby/Gems/1.8/gems/authlogic-oid-1.0.4/lib/authlogic_openid/session.rb:47:inauthlogic- oid-1.0.4/lib/authlogic_openid/session:rb:53:in credentials ='authlogic(2.1.2)lib /authlogic/session/foundation.rb:28:in initialize'
authlogic (2.1.2) lib/authlogic/session/password.rb:140:in初始化'authlogic(2.1.2)lib/authlogic/session/activation.rb:48:initialize'
authlogic (2.1.2) lib/authlogic/session/klass.rb:61:in初始化'authlogic(2.1.2)lib/authlogic/session/scopes.rb :79:在initialize'
app/controllers/user_sessions_controller.rb:10:in新的'app/controllers/user_sessions_controller.rb中:10:在'create'中
有没有人面临同样的问题?我正在使用rails 2.3.4
我已经尝试了二进制的示例应用程序,它运行得非常好(rails 2.1.2),我已经尝试了ryan bates提供的代码,它也运行良好(rails 2.3.2).因此,这些库正在使用以前版本的rails.
有线索吗?
authentication ruby-on-rails authlogic authlogic-oid railscasts
我刚刚在Elasticsearch上观看了两个Railscast的剧集.我也继续将它实现到我的rails应用程序(3.1)中,一切都运行良好.我如何将我的应用程序部署到Heroku,但我不确定如何让Elasticsearch在Heroku上运行(特别是在雪松堆栈上).
任何帮助将不胜感激!
full-text-search ruby-on-rails heroku railscasts ruby-on-rails-3
我试图抽象一些将图像裁剪成模块所需的逻辑,这样就不会弄乱我的模型.该代码基于http://railscasts.com/episodes/182-cropping-images
module CroppableImage
def croppable_image(*image_names)
image_names.each do |image_name|
define_method "#{image_name}_sizes" do
{ :cropped => read_attribute("#{image_name}_size").to_s, :large => "800x800>" }
end
define_method "#{image_name}_geometry" do |style|
style ||= :original
@geometry ||= {}
@geometry[style] ||= Paperclip::Geometry.from_file(eval "#{image_name}.path(style)")
end
define_method "#{image_name}_aspect_ratio" do
width, height = read_attribute("#{image_name}_size").split("x")
width.to_f / height.to_f
end
private
define_method "reprocess_#{image_name}" do
eval "#{image_name}.reprocess!"
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
要将其包含在我的模型中,似乎我必须使用extend.我认为扩展是为了包括类方法.我来自java背景 - 我认为使用extend基本上在类上创建了静态方法.
class Website < ActiveRecord::Base
extend CroppableImage
croppable_image :logo, :footer_image
Run Code Online (Sandbox Code Playgroud)
- 这很有效
那时我真正想要的是创建实例方法.
class Website < ActiveRecord::Base
include CroppableImage
croppable_image :logo, …Run Code Online (Sandbox Code Playgroud) 我一直在观看和重现我的应用程序上的这些railscast:196-nested-model-form-part-1和197-neested-model-form-part-2.我还没有专业帐户,所以我无法观看修改后的剧集.
我正在rails4(edge)下开发并且link_to_function已经被弃用而不喜欢不引人注目的JS(这很棒).
我将保留上述railscast的示例(即调查/问题).我想做的是使用问题的部分通过不引人注目的JavaScript,我只是不知道我应该如何以及在哪里做到这一点.
我想到了两种方法:
app/assets/javascripts的文件surveys.js与功能,add_question但我不知道如何从这里使用我的部分.SurveyController使用部分问题作出回应,但我对调查控制器中的问题采取特定行动的事实感到困扰.我不禁认为必须有更好的方法来做到这一点.
我在SO上看过ActiveRecord :: DangerousAttributeError和其他类似的线程,但它们没有解决同样的问题.
我正在关注omniauth教程:http://railscasts.com/episodes/235-omniauth-part-1?view = ascicast
我可以使用Twitter通过oauth进行身份验证并返回用户的数据(auth).问题是由于此错误消息,我无法在数据库(sqlite3)中创建/保存它.
ActiveRecord::DangerousAttributeError in AuthenticationsController#create
create is defined by ActiveRecord
Rails.root: /beta/devise-omniauth1
Application Trace | Framework Trace | Full Trace
app/controllers/authentications_controller.rb:15:in `create'
Run Code Online (Sandbox Code Playgroud)
def create
auth = request.env["omniauth.auth"]
current_user.authentications.create(:provider => auth['provider'], :uid => auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
end
Run Code Online (Sandbox Code Playgroud)
class Authentication < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_many :authentications
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and …Run Code Online (Sandbox Code Playgroud) 我尝试重现http://railscasts.com/episodes/346-wizard-forms-with-wicked railscast.我尝试用四步向导创建报告.一世
现在我尝试调用它(就像在railscats中通过在浏览器的地址栏中键入 localhost:3000/report_steps/step1)并接收:
Routing Error
uninitialized constant ReportStepsController::Wicked
Run Code Online (Sandbox Code Playgroud)
问题是什么?我使用ruby 1.9 2和rails 3.0.12.
UPD:评论和取消注释后包括Wicked :: Wizard行为改变了(这是一种魔法)现在我收到了新的错误:
NameError in ReportStepsController#show
uninitialized constant ReportStep
Run Code Online (Sandbox Code Playgroud) 我跟随了Ryan Bate的railscast#106 http://railscasts.com/episodes/106-time-zones-revised,它为用户模型添加了一个time_zone字符串.该字符串来自下拉列表:
= f.time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones
Run Code Online (Sandbox Code Playgroud)
我正在尝试查询共享公共时区偏移的所有用户(因此我可以在每天的特定时间向他们发送电子邮件).
User.where(:time_zone => ['Guadalajara','Central America','Mexico City', 'Monterrey', 'Saskatchewan'])
Run Code Online (Sandbox Code Playgroud)
我无法获得特定偏移的时区名称列表.我一直在修补TzInfo和ActiveSupport :: TimeZone.zones_map,但收效甚微.我觉得zones_map应该能够满足我的需求,但是我无法从中得到我想要的数据(尽管我在那里看到它!).
我在这里采取了错误的做法吗?我以为我可以将GMT偏移存储在用户身上,并以这种方式查询?
我的google-fu让我失望了.
railscasts ×10
omniauth ×3
ruby ×3
activerecord ×1
ajax ×1
authlogic ×1
carrierwave ×1
facebook ×1
gem ×1
heroku ×1
nested-forms ×1
timezone ×1
wizard ×1