草庐IT

how-can-i-auto-size-the-column-wi

全部标签

ruby-on-rails - pg_search 使用 associated_against 给出错误 "column [model_name].[associated_column_name] does not exist"

我正在尝试使用pg_search来搜索关联模型。当我运行搜索时,出现错误“PG::Error:ERROR:columnplans.namedoesnotexist”。我正在“计划”模型中运行搜索,并尝试针对“地点”与列“名称”的关联进行搜索。连接这些的has_many:through模型是多态的。不知何故,sql查询将两者结合起来并抛出错误。我已经运行了associated_against迁移(railsgpg_search:migration:associated_against),搜索了文档,并寻找其他有错误的人,但一无所获,一定是我只是忽略了一些东西。如果我只是删除plan.rb

ruby-on-rails - Ruby on Rails + 设计 + I18n : how to set locale?

我在ApplicationController中使用before_filter为我的应用程序设置语言环境:classApplicationController它适用于我编写的Controller。但是所有devise的消息仍然是英文。在config/application.rb中设置config.i18n.default_locale="uk"(或其他)有效,所以我猜问题在于设计的Controller确实不要使用我的before_filter(可能它根本不继承ApplicationController(?))。如何解决这个问题?如何让设计使用我的语言环境?

ruby-on-rails - 如何在 rails 中使用载波 'after the fact' 裁剪图像?

我想做的是上传一张图片,然后将用户带到一个新页面,我将在该页面上使用Jcrop让用户选择他们想要裁剪的图片部分,然后存储该图片。本质上,我想让它成为一个两阶段过程。我知道如何执行javascript部分,并且我了解如何创建此功能的基本流程。但是,我不知道关于如何实现此目的的载波细节。我能找到的最接近的是:image.recreate_versions!但我仍然无法传入高度/宽度和开始x,y来裁剪它。例如,我如何告诉carrierwave在“事后”进行裁剪-即不是在第一次上传图像时?我看到了“处理”图像的方法,但它们会以固定的高度和宽度自动发生。我该如何延迟呢?本质上,我想做的是动态定义

ruby-on-rails - rails : How to to download a file from a http and save it into database

我想创建一个RailsController,从网上下载一系列jpg文件,并直接将它们作为二进制文件写入数据库(我不是要上传表格)关于如何做到这一点的任何线索?谢谢编辑:这是我已经使用attachment-fugem编写的一些代码:http=Net::HTTP.new('awebsite',443)http.use_ssl=truehttp.verify_mode=OpenSSL::SSL::VERIFY_NONEhttp.start(){|http|req=Net::HTTP::Get.new("image.jpg")req.basic_authlogin,passwordrespon

ruby-on-rails - 事件管理员 : sorting on multiple columns

ActiveAdmin似乎还不支持多列排序(即将多个值传递给config.sortable选项)。我看到一个老猴子补丁here但它似乎不适用于我的版本(来自Github的1.0.0.pre)。有没有办法在最新的ActiveAdmin版本上获得多个可排序的列? 最佳答案 这也是一个猴子补丁:在config/initializers或lib文件夹中创建一个新文件:multiple_columns_sorting.rbmoduleActiveAdminclassResourceController重启服务器。现在您可以使用由"_and_"

ruby-on-rails - ruby rails : How do you list the partial paths that are rendered for a page?

我希望列出为我的应用程序中的每个页面呈现的部分内容。例如,当显示app/tasks/index.html.erb页面时,我想向用户显示如下内容:Partialsrenderedforthispage:tasks/_list.html.erbtasks/_button.html.erbtasks/_navigation.html.erb在RubyonRails中有什么方法可以做到这一点吗? 最佳答案 是的,在Rails中完全可以做到这一点!正如bdares在他的评论中指出的那样,用于模板渲染的行出现在日志中。但他们最初是如何到达那里的

ruby - `-' : nil can't be coerced into Fixnum (TypeError)

在我的程序中,我收到一条错误消息,显示./ruby_camping.rb:91:in`-':nilcan'tbecoercedintoFixnum(TypeError)。我想做的是为我刚刚入住的客人结账。这是结账部分的代码块:defself.check_outputs"Welcometocheckout!"puts$camping.current_guestsputs"Herearethecurrentguests,whodoyouwanttocheckout?!"puts"Stateplotnumber"plot=gets.chomp.to_iguest=$camping.curre

ruby-on-rails - rails/Prawn : how do I use rails helpers inside a Prawn class?

我正在尝试在prawn类中使用rails3.2助手,但rails抛出:undefinedmethod`number_with_precision'for#Prawn类classQuotePdfControllerdefshow@quote=current_user.company.quotes.where(:id=>params[:id]).firsthead:unauthorizedandreturnunless@quoterespond_with@quote,:layout=>!params[:_pjax]do|format|format.pdfdosend_dataQuotePd

ruby-on-rails - RubyOnRails : How do I use helper methods in Rails Console?

可能是我的设置有问题:irb(main):001:0>truncate("Onceuponatimeinaworldfarfaraway",:length=>17)NoMethodError:undefinedmethod`truncate'formain:Objectfrom(irb):1from/usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in`start'from/usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.8/lib/ra

ruby-on-rails - PinsController#index : declare the formats your controller responds to in the class level 中的运行时错误

在我的Rails应用程序上工作时,我在终端中使用以下命令创建了一个“Pins”脚手架:railsgeneratescaffoldPinsdescription:string--skip-stylesheets这会在我的应用程序中创建脚手架,然后我运行:rakedb:migrate一切顺利。我没有更改任何生成的页面,但是当我最终尝试访问localhost:3000上的新脚手架时,出现以下错误:RuntimeErrorinPinsController#indexInordertouserespond_with,firstyouneedtodeclaretheformatsyourcontr