Tag: 的Ruby on 轨道

Facebook登录OmniAuth错误更改被拒绝

我能够使用Omniauth http://railscasts.com/episodes/241-simple-omniauth我的Rails应用程序设置我的Facebook和Twitter登录。 我的登录工作在我的计算机上完美运行(我在生产和开发方面进行了测试),直到有人在尝试使用Facebook登录时通过电子邮件向我发送此问题时才发现问题: The change you wanted was rejected. Maybe you tried to change something you didn’t have access to. 事实certificate,在我的开发计算机上,没有其他人可以通过FB或Twitter登录或创建帐户。 从其他解决方案中,我删除了protect_from_forgery并将skip_before_filter :verify_authenticity_token添加到我的application_controller.rb,但我仍然遇到同样的问题。 我正在Heroku上托管我的应用程序。 有谁知道发生了什么? 如果您需要任何其他信息,请告诉我。

为什么我在前2位用户之后收到“此授权码已被使用”?

我正在使用Omniauth-Facebook来创建和validation用户。 它适用于两个第一个用户,但第三个用户失败。 我仍然可以进行身份​​validation; 这是CREATE过程失败了。 如果没有解决方案,这似乎是一个常见问题。 error.log中: facebook) Callback phase initiated. (facebook) Authentication failure! invalid_credentials: OAuth2::Error, : {“error”:{“message”:”This authorization code has been used.”,”type”:”OAuthException”,”code”:100}} onmiauth.rb: Rails.application.config.middleware.use OmniAuth::Builder do provider :developer unless Rails.env.production? provider :facebook, ‘xxxxxxx’, ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxx’, :scope => ’email,user_birthday,user_hometown,user_location’, :display => ‘popup’ end SessionsController: class SessionsController “Signed in!” end def destroy session[:player_id] = nil redirect_to root_url, :notice […]

如何将子域映射到localhost中的现有控制器操作

我想为这个特定的路线设置一个子域 get ‘product_list/home’ 以前url曾经像localhost:3000/product_list/home 。 现在我希望url为store.dev:3000/product_list/home 我修改了这样的路线 constraints subdomain: ‘store’ do get ‘product_list/home’ end 在/ etc / hosts中。 我添加了store.dev如下 127.0.0.1 localhost 127.0.0.1 store.dev 但是当在开发环境中访问store.dev:3000时,我的主页就像localhost:3000 。 但我想将我的子域限制为仅此路由product_list/home 。 我面临的另一个问题是 http://store.dev:3000/product_list/home当我访问这个时 我得到了这个 No route matches [GET] “/product_list/home” 更新: 更改hosts文件中的条目..从store.dev为store.local.dev它可以访问store.local.dev:3000/product_list/home. 但我的问题是我也可以访问其他页面,比如说我有about页面的信息。 store.local.dev:3000/about ,但我不希望这种情况发生。 如何将子域限制为仅一个特定路由

在Rails2中进行主持模型编辑

我想允许用户编辑模型,添加图片,url和/或电话号码。 但是,我不希望这些更改在主持人确认之前显示。 但是,我希望允许用户无需审核即可创建新条目,但不能包含图片,url和/或电话号码(它们可以包含名称和姓氏等基本详细信息)。 或者更好的是,它们可以包括图片等,但是在开始时,只有基本信息才会显示,直到主持人接受图片等。 我正在使用Rails 2.3.5。

使用RVM安装Ruby的问题:rvm install 1.8.7,rvm install 1.9.2

我在使用rvm安装ruby时遇到问题。 我目前正在运行Mac OS X 10.6.8。 加载rvm并重新启动Terminal后,我运行了脚本: $ rvm get latest (rvm update –head returned an error message: “ERROR: rvm update has been removed. See ‘rvm get’ and rvm ‘rubygems’ CLI API instead”) $ rvm reload 现在我遇到了问题: $ rvm install 1.8.7 获得以下回报: —————————————————————————————- Installing Ruby from source to: /Users/user/.rvm/rubies/ruby-1.8.7-p352, this may take a while depending on […]

Rails 2:使用form_for构建一个覆盖同一类的多个对象的表单

希望对于Rails maven来说这是一个扣篮: 我有一个表格应该迭代一组LineItems并收集每个。 我试图让form_for和fields_for创建正确的字段名称和参数,以给我的控制器一个params散列像 params[:line_items] = { => { :rma_reason => “some string”, :rma_qty => 2 } } 我所拥有的是: …. item.quantity, :size=>3 %> …. 结果HTML看起来像(我猜你会想到的): 然而 ,我想要获得的(并且没有找到除了回到ad-hoc HTML标签之外的任何解决方案)是由line_item.id索引的字段名称,例如line_item [1928] [rma_qty]。 这将允许我的控制器迭代每个line_item并使用给定的参数更新它。 …也许在纯REST UI中,表单应绑定到LineItem一个实例,标准form_for可以工作 – 但用户应该能够使用一个表单一次提交所有更改。 可能吗?

嵌套关注的循环依赖

任何人都知道为什么,在我的生产服务器上我不能在模型中使用嵌套关注点? 我有一个模型Landing class Landing < ActiveRecord::Base include Claimable end 和关注 module Claimable extend ActiveSupport::Concern end 一切都工作正常,但Claimable严格登陆逻辑,所以我想把它作为一个嵌套的路线 class Landing < ActiveRecord::Base include Landing::Claimable end 和 module Landing::Claimable extend ActiveSupport::Concern end 这是在我的开发机器(OSX Yosemite)上工作,但当我部署到Linux生产服务器时,我收到错误: /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:492:in `load_missing_constant’: Circular dependency detected while autoloading constant Landing::Claimable (RuntimeError) from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing’ from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:20:in `’ from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:18:in `’ from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require’ from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in […]

Check_box_tag不会在rails app中保留值

我有一个名为“客户”的模型。 客户端模型属于用户模型(用户模型与设计相关联)。 还有另一种称为“卖家”的模型,但他们没有涉及这个问题。 客户可以手动向我付款(仅限现金)。 当客户付款时,我会让他们访问网站上的更多页面。 为此,我向客户添加了一个名为“付费”的布尔变量,然后管理员(我)可以转到他们的客户档案,通过复选框将付费状态从“未付”更新为“付费”。 只有管​​理员才能查看该复选框。 这是更新客户信息的部分forms: 然后我的客户端控制器是: class ClientController < ApplicationController before_action :find_client, only: [:show, :edit, :update, :destroy] def index end def show end def new @client = current_user.build_client end def create @client = current_user.build_client(client_params) if @client.save redirect_to clients_path else render 'new' end end def edit end def update end def destroy @client.destroy […]

Rails中的序列号

我有一个具有seq (序列号字段)的Rails应用程序。 我希望它是一个不可见的字段,并且它可以自动递增,但与id分开。 在索引页面上,我希望能够拖放行来重新排序它们,然后序列应该从1到最高行。 这样做的简单方法是什么,或者任何人都可以建议我可以遵循的教程?

启动rails服务器Sidekiq时出错

当我试图启动我的服务器 rails s 给我以下错误 管理员/ .rvm / gems / ruby​​-1.9.3-p392 / gems / bundler-1.11.2 / lib / bundler / runtime.rb:81:在`rescue in block(2级)in require’中:出现错误在尝试加载gem’sidekiq’时。 (捆扎机:: GemRequireError) gem list sidekiq(4.0.1) 如果您知道如何解决此问题,请帮忙。