jjzjj

ruby-on-rails - Railstutorial : db:populate vs. 工厂女孩

在railstutorial中,作者为什么选择使用这个(代码list10.25):http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-usersnamespace:dbdodesc"Filldatabasewithsampledata"task:populate=>:environmentdoRake::Task['db:reset'].invokeUser.create!(:name=>"ExampleUser",:email=>"example@railstutorial.org",:passwo

ruby-on-rails - 撤消 "rails generate scaffold"后是否需要撤消 "db:migrate"?

我是RoR的新手,我正在学习MichaelHartl的教程(所以请随意更正我在您认为合适的地方使用的术语)。在第2章中,我通过运行以下行创建了一个Users表:$railsgeneratescaffoldUsername:stringemail:string$bundleexecrakedb:migrate然后,我运行了下面的代码来尝试创建一个Microposts表(但是,我拼错了没有“r”的Micropost!)...$railsgeneratescaffoldMiropostcontent:stringuser_id:integer$bundleexecrakedb:migrate

ruby-on-rails - 模型范围正在破坏 rake db :migrate - rails 3. 2.3 postgres 9.1.3

我在新的Rails应用程序(3.2.3)中运行迁移时遇到了问题。我们正在使用postrgres9.1.3和-pg(0.13.2)-当我运行rakedb:create,然后运行​​rakedb:migrate,我得到->1.9.3-p194(master)rakedb:migrate--trace**Invokedb:migrate(first_time)**Invokeenvironment(first_time)**Executeenvironmentrakeaborted!PG::Error:ERROR:relation"roles"doesnotexistLINE4:WHEREa

ruby-on-rails - 奇数 rake db :migrate output

为什么rakedb:migrate运行Executedb:schema:dump我的输出全都搞砸了(显示SQL)。看起来像这样:ActiveRecord::SchemaMigrationLoad(0.5ms)SELECT"schema_migrations".*FROM"schema_migrations"(3.7ms)SELECTt2.oid::regclass::textASto_table,a1.attnameAScolumn,a2.attnameASprimary_key,c.connameASname,c.confupdtypeASon_update,c.confdeltyp

ruby - 没有 nginx 的 Puma - 同一 IP 上的多个 ruby​​ 应用程序 :PORT

Nginx在生产中的重要性通常基于它为慢速客户端提供服务的能力;在RESTfulAPI的设置中,它似乎是生产堆栈的一个不必要的层,尤其是Puma(不像广泛使用的unicorn可以处理nginx工作)。Pumacanallowmultipleslowclientstoconnectwithoutrequiringaworkertobeblockedontherequesttransaction.Becauseofthis,Pumahandlesslowclientsgracefully.HerokurecommendsPumaforuseinscenarioswhereyouexpect

ruby-on-rails - Faraday::ConnectionFailed,Connection refused - connect(2) for “localhost” port 9200 Error Ruby on Rails

我正在尝试使用RubyonRails在我的应用程序中添加Searchkickgem,但是当我在搜索框中键入一个词时,我的应用程序中出现此错误。我已经根据需要安装了elasticsearch和最新版本的java,但错误仍然是一样的。这是我得到的错误:Faraday::ConnectionFailedinPostsController#searchConnectionrefused-connect(2)for"localhost"port9200这是我的代码:终端显示已安装Elasticsearch:终端Warning:elasticsearch-1.7.3alreadyinstalled

ruby - Rails 3 db :migrate 的未定义方法 `visitor'

我在Rails3中进行数据库迁移时遇到异常。undefinedmethod`visitor'for#编辑请查看解决方案here.在我的项目中没有出现字符串visitor所以我很困惑。这是完整的转储:$rakedb:migrate--trace**Invokedb:migrate(first_time)**Invokeenvironment(first_time)**Executeenvironment**Invokedb:load_config(first_time)**Invokerails_env(first_time)**Executerails_env**Executedb:l

ruby-on-rails - rake 数据库 :migrate not working on my postgres db

好的,所以我有一个Rails应用程序,我试图在postgres数据库上运行迁移,我通常使用mysql,一切都很好,但是当我运行命令时,我得到了这个rakedb:migrate(in/Users/tamer/Sites/my_app)/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487:[BUG]Segmentationfaultruby1.9.2p290(2011-07-09

ruby-on-rails - 运行 rake db :seed multiple times without creating duplicate records?

这个问题在这里已经有了答案:appendingtorakedb:seedinrailsandrunningitwithoutduplicatingdata(9个回答)关闭9年前。我想更改种子文件中的一些代码,以便在我多次运行种子命令时它不会创建重复记录。有什么方法可以从我的种子文件中修改下面的代码,这样就可以了吗?除非我弄错了,否则find_or_create_by方法在这里似乎不起作用。data_file=Rails.root.join('db/data/data.csv')CSV.foreach(data_file)do|row|TownHealthRecord.create(ci

ruby-on-rails - rake db :migrate doesn't work after ruby 2. 2.2 到 2.2.3 通过 RVM 升级

我最近使用RVM从Ruby2.2.2升级到2.2.3。这搞砸了我的开发环境中的一些事情,但由于有用的错误消息,到目前为止我可以处理它。现在我想向我的数据库添加一些迁移,但遇到了这个错误:$rakedb:migrate/Users/howard/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in`eval':/Users/howard/.rvm/rubies/ruby-2.2.3/bin/rake:4:syntaxerror,unexpectedtSTRING_BEG,expectingkeyword_door'{'or'('(Syn