草庐IT

create_collection

全部标签

ruby-on-rails - rake db :create in Rails 的段错误

当我在中执行rakedb:create时,我遇到了段错误错误输出为:/home/[username]/.rvm/gems/ruby-1.9.2-p0/gems/sqlite3-1.3.3/lib/sqlite3/sqlite3_native.so:[BUG]Segmentationfaultruby1.8.7(2010-01-10patchlevel249)[i486-linux]Aborted我尝试按照http://guides.rubyonrails.org/getting_started.html上的示例教程进行操作我在一个全新的项目中遇到了同样的错误。

ruby-on-rails - rails : correct redirect but incorrect URL in address bar after creating into DB

在我的Rails应用程序中,我有一个这样的创建按钮defcreate@client=Client.find(params[:client_id])@inventory=@client.inventories.create(params[:inventory])redirect_toclient_path(@client)end创建库存时(作为客户端的一部分,例如客户端有很多库存,库存属于客户端),库存被添加到数据库中的客户端,并重定向到localhost:3000/client/(无论是客户ID是)但是,我的程序有问题,因为尽管它进行了正确的重定向,但在我推送创建后地址栏中的地址是lo

ruby-on-rails - 如何 stub after_create 回调保存!在模型中?

我收到以下错误:输出:1)LabelsController#createlabelisnewcreatesanewlabelFailure/Error:post:create,attributes[:label],format::jsonNoMethodError:undefinedmethod`save!'fornil:NilClass#./app/models/labeling.rb:17:in`update_target'在标签模型中:after_create:update_targetdefupdate_targetself.target.save!end测试:require'

ruby-on-rails - Carrierwave 文件上传在 ActiveRecord Create 上验证失败

所以我有一个非常直接的用于图像上传的Carrierwave实现。我已将uploader安装在ActiveRecord模型上:classMenuItem我使用的表单结合了编辑/创建上述MenuItem以及附加文件:"photo"%>@menuitem.active%>在编辑/更新的情况下,一切正常。但是,在New/Create上,我在:photo属性上收到验证错误,它只是说“照片无效”。上传者定义是普通的:classPhotoUploader100,:width=>100})sf.add_save("thumbnail",key,ENV['S3_BUCKET'])bs=Blitline.

ruby - 导轨 3.2 : how to find all parents from a collection of children

给定一组“书籍”,找到所有“作者”(无重复)的最佳方法是什么?假设我们有一个经典关联:classAuthor我现在的做法是这样的:@books=Book.where("somecondition")@authors=Author.where(:id=>@books.map(&:author_id))有没有更好的方法呢? 最佳答案 这里有一个方法:@books=Book.where("somecondition").includes(:author)@authors=@books.map(&:author).compact.uniq解

ruby-on-rails - rails : Create child/parent relationship

我无法将child添加到给定的parent。该View有一个“添加子项”链接,该链接传入当前的Person对象。从这里开始,我被困住了。父子都是Person对象。此外,逻辑很差-目前假设是父亲。模型(person.rb):classPerson"Person"belongs_to:father,:class_name=>"Person",:foreign_key=>'father_id'belongs_to:mother,:class_name=>"Person",:foreign_key=>'mother_id'defchildrenPerson.find(:all,:conditi

ruby-on-rails - rails 5 : How to pass collection_select values through strong_params in a fields_for?

我已经尝试了所有视频和文章,但仍然找不到将fields_forcollection_select值加入strong_params白名单的解决方案。我花了好几天时间想弄明白(并问了很多人)。如果有人能花时间帮助我,我将不胜感激!我在List和Topic之间有一个多对多的关联,List_Topic充当连接模型。使用form_for,我为List的一个实例(@list)创建了一个表单,然后是一个fields_for:list_topics。在字段中,我创建了一个collection_select,它由Topic.all填充。在我的列表Controller中我有:classListsContr

ruby-on-rails - ruby /rails : how can I create multiple records in salesforce with one API call via the rforce gem?

我正在使用rforcegem在我的salesforce数据库中创建记录。rforce文档中创建记录的例子是:opportunity=[:type,'Opportunity',:accountId,account_id,:amount,'10.00',:name,'FakeyMcFakerson',:closeDate,'2008-07-04',:stageName,'ClosedWon']binding.create:sObject=>opportunitySalesforceAPI调用create()允许一次创建多个对象,但我正在努力实现这一点。我尝试了以下调用:binding.cr

ruby-on-rails - 带有 :onchange and a :with 的 rails 2.1.2 collection_select

经过大量的搜索和阅读,我得到了一个看起来像这样的collection_select"this.value"},{:onchange=>remote_function(:url=>{:action=>"updatelevel",:controller=>"user",:id=>user.id})}%>但是它没有将选定的值传递给我的Controller,我唯一得到的就是一个nil。我搞砸了where:with应该是的不同组合并尝试了测试字符串,但它似乎从来没有做任何事情。我错过了什么愚蠢的东西吗?是否有我应该查看的“决定性”示例?Rails似乎变化如此之快,以至于很难知道论坛帖子谈论的是哪

ruby - rake db:create:ll 中#<Jquery::Rails::Engine:0x102530798> 的未定义方法 `namespace'

运行rakedb:create:all时出现以下错误:rakeaborted!undefinedmethod`namespace'for#rakefile如下所示:requireFile.expand_path('../config/application',__FILE__)module::TestProjectclassApplicationincludeRake::DSLendendmodule::RakeFileUtilsextendRake::FileUtilsExtendTestProject::Application.load_tasks这里出了什么问题?