草庐IT

select-multiple-images-from-andro

全部标签

ruby - Wicked-PDF 不显示图像, 'wicked_pdf_image_tag' 未定义

我想生成一个包含我们部门Logo的PDF。当我尝试在我的Controller中使用WickedPdf类时(使用https://github.com/mileszs/wicked_pdf中描述的方法):defsome_actionimage_tag_string=image_tag('logo.jpg')pdf=WickedPdf.new.pdf_from_string(image_tag_string)save_path=Rails.root.join('testpdfs','logotest.pdf')File.open(save_path,'wb')do|file|file...应

ruby - 在 collection_select rails 中选择多个选项

我知道如何组合一个从模型中获取值的简单选择框"PleaseSelectaSector")%>我的问题是如何允许用户选择多个选项,然后将它们存储在模型中。我知道我需要使用:multiple=>true但不确定语法通常对于一个模型的多个条目,我会使用accepts_nested_attributes_for,但我认为我不需要对这个例子这样做是否正确?谢谢 最佳答案 经过一些尝试和错误后确定"PleaseSelectaSector"},{:multiple=>true})%>让我选择多个选项

ruby-on-rails - 事件管理员 :select drop-down defaults to current value in development but defaults to blank in production

我有以下ActiveAdmin表单:formdo|f|f.inputs"TimesheetDetails"dof.input:jobs_assigned_worker,:label=>"Worker",as::select,collection:Worker.allf.input:worked_time_hours,:label=>"WorkedTime(Hours)"f.input:worked_time_mins,:label=>"WorkedTime(Minutes)"f.input:driving_time_hours,:label=>"DrivingTime(Hours)"f

ruby - ruby有数组方法select吗!或不?

>a=%w(abc)=>["a","b","c"]>a.select!{|e|!e.nil?}NoMethodError:undefinedmethod`select!'for["a","b","c"]:Arrayfrom(irb):2ruby1.8.7(2010-04-19patchlevel253)[i686-darwin10.5.0],MBARI0x6770,RubyEnterpriseEdition2010.02文档说有一个叫做select的方法!在数组中。http://www.ruby-doc.org/core/classes/Array.html#M000252

ruby-on-rails - Rails ActiveRecord::StatementInvalid: PG::Error: ERROR: 缺少表的 FROM 子句条目

我有一个复杂的ActiveRecord查询,我正在根据用户的选择构建具有不同范围的查询。我正在使用2个gem,这似乎是有问题的,但我找不到谁是两者之间的罪魁祸首:Texticle(用于Postgresql完整搜索)(2.0.3)Squeel(用于ActiveRecord查询中的ruby​​语法)squeel(0.9.5)Arel或ActiveRecord本身这是我的类定义:classEvent"Entity",:foreign_key=>:entity_idbelongs_to:place,:class_name=>"Entity",:foreign_key=>:place_idcla

ruby-on-rails - ruby rails : Properly creating a model instance that has relation to multiple models

假设我有一个独立的用户模型和服务模型。我还有一个订单模型,用于保存用户为某项服务创建的订单。我想知道如何在Rails中正确创建订单条目。以下是我将如何创建一个订单条目,如果它只引用一个其他模型,比如用户。@order=current_user.orders.build(params[:order])@order.save现在,如果订单涉及多个模型(用户和服务),我该怎么做?假设Order模型具有user_id和service_id属性,并且所有模型对象都正确标记了belongs_to和has_many关系。 最佳答案 @order=

ruby-on-rails - Rails 上的 ruby : How to have multiple submit buttons going to different methods (maybe with with_action? )

这个问题在这里已经有了答案:HowdoIcreatemultiplesubmitbuttonsforthesameforminRails?(7个答案)关闭9年前。所以..'save'%>'library'%>然后在我的Controller中:with_actiondo|a|a.savedoenda.librarydoendend问题是只有一个操作被调用...两个submit_tags调用相同的操作...知道为什么吗?或者我如何获得两个按钮以将表单提交给两种不同的方法?

ruby-on-rails - 回形针 :style depending on model (has_many polymorphic images)

我已将我的模型设置为使用多态图像模型。这工作正常,但我想知道是否可以更改每个模型的:styles设置。找到了一些使用STI(Model艺术has_many:images,:as=>:imageable图片belongs_to:imageable,:polymorphic=>truehas_attached_file:file,:styles=>{:thumb=>"150x150>",:normal=>"492x600>"}#Changethissettingdependingonmodel更新我尝试在Proc方法中启动调试器。仅填充与附件相关的字段:run'irb(Image):006

ruby-on-rails - f.collection_select 不显示选择的值

在google上有很多关于此搜索的结果,甚至有人在SO上询问过-但到目前为止讨论的解决方案对我没有帮助。问题是:我有一个form_for@company|f|并且我正在为company_status_id使用f.collection_select-但是当加载表单时,如果已设置,我希望选择实际的公司状态。通过我知道的调试器,它已被设置,但我在那里显示了一个默认值。这是代码:=puts@company.company_status_id=f.collection_select:company_status_id,ListCache.company_statuses,:id,:name,{:

ruby-on-rails - Rails 如何使用 image_tag 列出文件夹中的所有图像?

我正在尝试获取“app/assets/images/slide”文件夹中的所有图像并将它们放入标签(按顺序)。所以,它看起来像这样:我怎样才能做到这一点?(我使用的是Rails3.2.9)这是我试过的代码(感谢Khaled)。但它输出所有图像路径的纯文本列表。我需要显示图像:@images=Dir.glob("app/assets/images/slide/*.jpg")@images.eachdo|image|image_tagimage.gsub("app/assets/images/","")end 最佳答案 在您的Contr