草庐IT

adapt_struct

全部标签

ruby - Sinatra + Heroku + Datamapper 使用 dm-sqlite-adapter 部署问题

出于某种原因,heroku尝试要求dm-sqlite-adapter,即使它应该在这里使用Postgres。请注意,这发生在我打开任何URL时-而不是在gitpush本身期间。我构建了一个默认的Facebook应用程序。gem文件:source:gemcuttergem"foreman"gem"sinatra"gem"mogli"gem"json"gem"httparty"gem"thin"gem"data_mapper"gem"heroku"group:productiondogem"pg"gem"dm-postgres-adapter"endgroup:development,:t

ruby-on-rails - Rails/Mongoid 与 Struct 的关系问题

我正在构建这个图书馆应用程序,它有3个类。国家、图书馆和书籍。国家有许多图书馆,图书馆属于一个国家。图书馆有很多书,书是嵌入图书馆的。但是,当我执行此auto_pick_job时,我们到达top_free_book并调用library.state。由于某种原因,library.state为nil。我希望恢复状态但没有骰子。我调用和创建库的方式如下。所以图书馆将永远属于一个现有的国家。state=Stats.find(x)library=state.libaries.new(info)library.save_optimistic!我也很感激使用Struct的关系帮助。classStat

ruby - 安装 dm-mysql-adapter 时出错

我是Ruby的新手。我安装了DataMapper并且正在尝试安装dm-mysql-adapter-1.0.2gem。但是当我尝试安装时,出现以下错误。我正在使用ubuntu操作系统。vinoth@vinoth-laptop:~/Downloads$geminstalldm-mysql-adapter-1.0.2----with-mysql-lib=/usr/lib/mysql----with-mysql-conf=/usr/bin/mysqlWARNING:Installingto~/.gemsince/home/vinoth/gemsand/home/vinoth/gems/bina

ruby - "HTTPI tried to user the httpi adapter"使用 Savon SOAP 库时出错

我正在使用Savon为SOAP服务编写一个Ruby接口(interface)。它似乎正在工作,但我在命令行上出现了几条DEBUG消息D,[2011-02-15T16:33:32.664620#4140]DEBUG--:HTTPI尝试使用httpclient适配器,但无法在LOAD_PATH中找到库。后退现在使用net_http适配器。D,[2011-02-15T16:33:32.820863#4140]DEBUG--:HTTPI使用net_http适配器执行HTTPPOST我不确定为什么会出现这些消息,或者它们的含义。有什么想法吗? 最佳答案

ruby - gem 安装 dm-postgres-adapter 构建错误

我正在尝试构建dm-postgres-adapter但出现此错误。sudogeminstalldm-postgres-adapterBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingdm-postgres-adapter:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcheckingformain()in-lpq...y

c - Data_wrap_struct 和标记函数

我正在编写一个Ruby扩展,我正在使用函数Data_wrap_struct。为了参与Ruby的标记和清除垃圾收集过程,我需要定义一个例程来释放我的结构,以及一个例程来标记从我的结构到其他结构的任何引用。我通过经典的free函数来释放内存,但我不知道如何使用标记函数。我的结构听起来像这样typedefstruct{intx;inty;}A;typedefstruct{Acollection[10];intcurrent;}B;我认为我需要一个标记函数来标记结构B的collection中的引用。谁能给我看一个例子,看看标记函数是如何工作的? 最佳答案

Ruby Guard 问题 - 'Please install the sqlite3 adapter' - railstutorial.org

我正在关注RubyonRailsTutorial并且在测试部分变得有些困惑,特别是-3.6.2-AutomatedtestswithGuard按照部署到Heroku的教程说明,我已切换到Postgresql并从我的gemfile中删除了sqlite3,并进行了捆绑安装以进行更新。但是,一旦我运行bundleexecguard我收到消息:/Users/username/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.3/lib/bundler/rubygems_integration.rb:147:inblockinreplace_ge

ruby-on-rails - gem install json 失败,重新定义了 struct timezone/timespec

我在Windows上使用带有DevKit的Ruby1.9.3(在Win764位上都是32位)。现在我尝试安装rails,但从bundle中得到一个错误。如果我尝试运行(包在提示什么)geminstalljson我收到以下错误消息:D:\RubyTest>geminstalljsonTemporarilyenhancingPATHtoincludeDevKit...Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingjson:ERROR:Failedtobuildgemnativeextension.D:

ruby-on-rails - ActiveRecord .... activerecord-mysql-adapter

这让我发疯。我正在尝试创建一个简单的初学者应用程序,利用ActiveRecord来执行简单的数据库任务。我没有使用Rails。我不断收到错误:RuntimeError:Pleaseinstallthemysqladapter:`geminstallactiverecord-mysql-adapter`(Couldnotfindmysql(~>2.8.1)amongst[actionmailer-3.1.3,actionpack-3.1.3,activemodel-3.1.3,activerecord-3.1.3,activerecord-sqlserver-adapter-3.1.4,

ruby - 为什么我不应该扩展由 Struct.new 初始化的实例?

我们有一个遗留代码库,其中rubocop报告了一些我永远无法理解的错误:Don'textendaninstanceinitializedbyStruct.new.Extendingitintroducesasuperfluousclasslevelandmayalsointroduceweirderrorsifthefileisrequiredmultipletimes.究竟什么是“多余的类级别”,可能会引入什么样的“怪异错误”?(问是因为显然我们在过去几年没有遇到过任何此类问题。) 最佳答案 Struct.new创建一个匿名类,它