草庐IT

Example_Table

全部标签

ruby-on-rails - 在 Rails/Capybara/Poltergeist 规范中使用 url_for 将驱动程序发送到 example.com 而不是应用程序

如果我在功能规范中调用url_for,它会返回一个以http://www.example.com/开头的绝对URL.Capybara会很乐意尝试加载该站点上的页面,但这与我的应用程序无关。以下是重现该问题的最少步骤:从这个Gemfile开始:source'https://rubygems.org'gem"sqlite3"gem"jquery-rails"gem"draper"gem"rails",'4.1.0'gem"therubyracer"gem"uglifier"gem"rspec-rails"gem"capybara"gem"poltergeist"gem"launchy"运行

ruby-on-rails - Rails 查询 : Filter by properties in another table

我正在寻找一个清晰的Rails4示例,说明如何根据通过另一个表关联的数据过滤记录。假设我有一个用户模型和一个评论模型。一个用户has_many评论,一个Commentbelongs_to一个用户。评论在其表中也有一个score列。classUserUsers|id|name|email||-----|---------|---------------------||1|"Alice"|"alice@example.com"||2|"Bob"|"bob@example.com"||...|classComment我如何获得所有对内容“k”发表评论且分数>0的用户?请注意,我要返回的是用户

ruby-on-rails - rails 3/ActiveRecord : How to switch/change table name during request dynamically?

我想在请求期间动态更改ActiveRecord模型类的表名。例如,有许多具有相似结构(列)的表:mydb:sample_data_12222sample_data_12223sample_data_12224sample_data_12225...所以,我想做的是..._1。定义基本模型类,如:classSampleData_2。在请求期间更改目标表,例如:defaction_methodSampleData.set_table_name"sample_data_#{params[:id]}"@rows=SampleData.all如果在非线程环境(如Passenger/mod_rai

ruby-on-rails - 如何在 Prawn 中居中 table ?

我在prawn中创建了一个表,并希望通过whih传递:position选项,这在手册中也有记录,但它引发了Method_missing错误。好像这个参数不存在了。我怎样才能让Prawn居中? 最佳答案 我遇到了同样的错误。从Github上的master安装解决了这个问题。#Gemfilegem'prawn',git:'https://github.com/prawnpdf/prawn.git'IssuethreadonGithub 关于ruby-on-rails-如何在Prawn中居中t

ruby - 融合表 : Why do I keep getting a "400 Bad Request" error when trying to update a table style via Ruby's RestClient gem

我正在尝试使用RubygemRestClient为我的一个FusionTables更新样式。这是我的代码:require'rest_client'tableId=''styleId=''key=''table_url="https://www.googleapis.com/fusiontables/v1/tables/#{tableId}/styles/#{styleId}?key=#{key}"update='{"polygonOptions":{"strokeColor":"#ffffff"}}'token='STRINGCONTAININGAUTHORIZATIONTOKEN'R

ruby-on-rails - Rails SSL 问题 : (https://example. com) 与 request.base_url (http ://example. com) 不匹配

我刚刚在我的网站上安装了SSL证书。不幸的是,它破坏了登录功能。在网站上提交登录表单后,它只是重定向到主页。检查Rails日志显示此错误:(https://example.com)didn'tmatchrequest.base_url(http://example.com)这是我的虚拟主机文件。我想我需要以某种方式强制使用SSL?ServerNameexample.comServerAliaswww.example.comRedirectpermanent/https://example.com/ServerAdminhello@example.comServerNameexample

ruby-on-rails - Heroku Drop Table Rails 帮助

我正在使用RubyonRails,我不再需要我的表Order,所以我使用SQLite管理器删除了它。我怎样才能在heroku中删除表?编辑我收到错误db/migrate/20110806052256_droptableorders.rb:10:syntaxerror,unexpectedkeyword_end,expecting$end当我运行命令时classDropTableOrder 最佳答案 如果你不想创建一个迁移来删除表并且不能回滚以前的迁移,因为你不想丢失迁移后创建的表中的数据,你可以在heroku控制台上使用以下命令来放

Ruby 1.9.3 - CSV.table 如何知道 CSV 文件中是否没有 header ?

我一直在用CSV.table做一些测试。我有两个几乎相同的小CSV文件,但其中一个缺少标题行。当我对带有标题行的CSV文件运行CSV.table时,一切都按预期进行。当我针对没有标题行的CSV文件运行它时,我得到:NoMethodError:undefinedmethod`encode'fornil:NilClass我用不同类型的数据、不同类型的header尝试了这个,并得到了相同的结果。我很好奇CSV.table的魔力。如果我使用CSV.parse并将标题设置为true,那么无论如何它总是使第一行成为标题。所以,我一直在使用CSV.table来检查导入的CSV文件是否有标题行,但我对

轨道上的 ruby : How to create table for a new model

我用railsgeneratemodelmynewmodelstring:namestring:description生成一个新模型。如何将这个新模型部署到我的开发数据库中?我的sqlite数据库中已经有一堆数据库。我试过了rakedb:migrate在db中生成这个新表似乎有问题。更新:添加了错误信息==CreateMynewmodels:migrating===============================================--create_table(:mynewmodels)rakeaborted!Anerrorhasoccurred,thisandal

ruby-on-rails - PGError : ERROR: relation "table_name" does not exist

我正在尝试将一个简单的应用程序推送到heroku并运行:herokurakedb:migrate但是我得到以下错误:rakeaborted!PGError:ERROR:relation"posts"doesnotexist:SELECTa.attname,format_type(a.atttypid,a.atttypmod),d.adsrc,a.attnotnullFROMpg_attributeaLEFTJOINpg_attrdefdONa.attrelid=d.adrelidANDa.attnum=d.adnumWHEREa.attrelid='"posts"'::regclass