Tag: 的Ruby on 轨道

Rails,production-env,“Object is not missing constant”

所以我似乎是愚蠢的,并没有检查生产env运行很长一段时间,现在我正在尝试部署,我得到这个恼人的错误。 有任何想法吗? LIB / history_tools.rb module HistoryTools def self.included(base) base.has_many :history, :dependent => :destroy History::TYPES.each do |htype| base.has_many “history_#{htype}”, :class_name => “History::#{htype.capitalize}” end end # … other minor things removed … end 应用程序/模型/ user.rb class User < InheritedResources::Base include HistoryTools end 到config / environment.rb # … the usual stuff, then, at the very bottom: require […]

如何设置轮胎弹性搜索的默认分析器?

我最近一直在尝试使用ruby on rails。 我无法将数据编入索引,因此我可以搜索包含复数和非复数关键字的项目。 轮胎将允许我为每个映射属性分配一个分析器: mapping do indexes title, analyzer: ‘snowball’ indexes body, analyzer: ‘snowball’ end 现在,假设我在“测试”标题中有一个关键字 如果我使用查询中的属性进行搜索: http:// localhost:9200 / myindex / mymapping / _search?q = title:test它将起作用。 但是,如果我在没有指定属性的情况下进行常规搜索,则: HTTP://本地主机:9200 / myindex / mymapping / _search Q =测试 它找不到该文件。 如何指定我希望默认分析器为“雪球”,因此我不必指定要搜索的属性? ps我正在使用轮胎gem。 所以请尽可能地回答这个问题。

我怎么能有时需要密码,有时候不需要使用has_secure_password?

我的应用程序允许人们使用密码或Facebook注册。 即使我从用户模型中删除了密码validation,我也会在用户模型上获得:password_digest => [“can’t be blank”] 。 我使用has_secure_password 。 如何才能使password_digest不需要?

在Rails应用程序中添加wordpress博客

我将Rails应用程序部署在域的主目录上,并使用我的public_html / applicationname.com /进行符号链接。 我想在applicationname.com/blog路径中安装wordpress。 但轨道不允许我这样做。 我也试过了一个子域名,但Rails还是处理了这些路由。 与Rails应用程序一起部署博客的最佳解决方案是什么? 我只能想到.htaccess修改。

谷歌地图自动完成js正在localhost上工作但不在heroku上工作

我是铁轨开发人员的初级ruby。 我开发了一个使用谷歌地图JavaScript API的网络应用程序,我在表单输入上使用自动完成function。 自动完成在localhost上正常工作,但在heroku上部署后不再起作用。 这是我的html.erb。 为了获得完美的信息,表单位于页脚中。 此表单是部分隐藏的,唯一可见的部分对应于用于上传video文件的按钮。 单击此按钮并选择video文件后,我将显示包含表单其余部分的模式。 这就是显示’text_field_tag’(id =“user_input_autocomplete_address”)并且自动完成应该在哪里工作的地方。 Place Comment $(‘#review_video’).change(function(){ $(‘#myModal’).modal(‘show’); }); 页脚(收集模态和表单)在layouts / application.html.erb视图中调用,如下所示。 您会看到我在那里使用Google API密钥(隐藏在application.yml中) <meta name="msapplication-TileImage" content="”> <meta name="description" content="”> <meta property="og:title" content="” /> <meta property="og:url" content="” /> <meta property="og:image" content="” /> <meta property="og:description" content="” /> <meta property="og:site_name" content="” /> <meta name="twitter:site" content="”> <meta name="twitter:title" content="”> <meta name="twitter:description" content="”> […]

Facebook应用程序 – 通过omniauth登录 – OAuthException 191

我面临的问题是: “error”: { “message”: “Invalid redirect_uri: Given URL is not allowed by the Application configuration.”, “type”: “OAuthException”, “code”: 191 } 我在我的应用程序中设置了所需的密钥和令牌,在Facebook的开发中心我设置了Site URL:到http://127.0.0.1:3001我收到上面的错误。 此外,我尝试设置App Namespace:到http://127.0.0.1:3001 ,但我收到有关错误地址格式的错误…当我试图填写他的App Domain:并设置我的localhost,再次格式错误的错误…… 使用localhost的fabebook应用程序的正确配置是什么?

`’:类Server的超类不匹配(TypeError)

我已经看到了这个和其他几个问题,但他们的问题与我的不相似。 我已将以下代码添加到config/boot.rb ,以便在端口8081上运行我的服务器 module Rails class Server def default_options super.merge({Port: 8081}) end end end 然后我试着运行rails s ,我面对这个erorr: /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:7:in `’: superclass mismatch for class Server (TypeError) from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:6:in `’

Rails 4 – 从渲染中删除“created_at”和“updated_at”

当我想从一个资源中删除这些数据时,我会: @teams = Team.all render json: @teams, :except => [:created_at, :updated_at], 我怀疑的是,当我有许多这样的包括: @teams = Team.all render json: @teams, :include => [:stadiums, :scores, :links, :rounds] 如何从所有这些中删除?

activerecord如何知道执行插入或更新?

也许一些ruby专家可以在调用save()时了解activerecord如何知道插入或更新。 它背后的逻辑是什么? 它检查主键是否为空或其他什么,如果是,是否插入,如果不是更新?

数组中的“each”/“map”会在create_time_zone_conversion_attribute中导致“你没有想到它时有一个nil对象”,偶尔会

我有一个按钮,它通过XHR向rails服务器中的特定操作发送get请求。 此操作调用我在模型“类别”中定义的函数。 这个函数做x = Category.subcategories之类的东西,下一行就像x.map(&:id)或x.each {| x | y << x.id}。 (类别has_many:子类别)。 在我的开发环境中,这个按钮只需1-10次点击,但由于以下原因停止工作: You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include? 使用以下转储: C:/MyApp/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?’ C:/MyApp/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:75:in `define_attribute_methods’ C:/MyApp/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in `each’ C:/MyApp/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods’ C:/MyApp/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:355:in `respond_to?’ C:/MyApp/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `method_missing’ C:/MyApp/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `map’ C:/MyApp/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `send’ C:/MyApp/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in […]