我尝试使用,gem install pg但它似乎没有用.
gem install pg 给出了这个错误
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. …Run Code Online (Sandbox Code Playgroud) 当我这样做
ip = request.env["REMOTE_ADDR"]
Run Code Online (Sandbox Code Playgroud)
我得到了客户端的IP地址.但是如果我想验证变量中的值是否真的是IP呢?我怎么做?
请帮忙.提前致谢.抱歉,如果重复这个问题,我没有努力找到它......
编辑
那么IPv6 IP呢?
使用Postgres DB的简单rails应用程序,在尝试插入2176968859时出现"整数超出范围"错误.应该可以轻松修复迁移,但我不确定.现在我有......
create_table :targets do |t|
t.integer :tid
...
end
Run Code Online (Sandbox Code Playgroud) 我正在使用本指南在heroku上集成wicked_pdf.但不知何故它似乎不起作用.我从heroku获得了日志,它说:
Processing PdfController#get_pdf to pdf (for 115.248.175.50 at 2011-02-15 23:54:44) [GET]
Parameters: {"format"=>"pdf", "action"=>"get_pdf", "id"=>"1", "controller"=>"pdf"}
***************WICKED***************
Rendering pdf/get_pdf
RuntimeError (PDF could not be generated!
/usr/ruby1.8.7/lib/ruby/1.8/open3.rb:73:in `exec': No such file or directory - /app/fa369291-829b-4b61-9efe-b2f0d0a0a42c/home/bin/wkhtmltopdf-amd64 - - (Errno::ENOENT)
from /usr/ruby1.8.7/lib/ruby/1.8/open3.rb:73:in `popen3'
from /usr/ruby1.8.7/lib/ruby/1.8/open3.rb:59:in `fork'
from /usr/ruby1.8.7/lib/ruby/1.8/open3.rb:59:in `popen3'
from /usr/ruby1.8.7/lib/ruby/1.8/open3.rb:57:in `fork'
from /usr/ruby1.8.7/lib/ruby/1.8/open3.rb:57:in `popen3'
from /app/fa369291-829b-4b61-9efe-b2f0d0a0a42c/home/vendor/plugins/wicked_pdf/lib/wicked_pdf.rb:22:in `pdf_from_string'
from /app/fa369291-829b-4b61-9efe-b2f0d0a0a42c/home/vendor/plugins/wicked_pdf/lib/pdf_helper.rb:28:in `make_pdf'
from /app/fa369291-829b-4b61-9efe-b2f0d0a0a42c/home/vendor/plugins/wicked_pdf/lib/pdf_helper.rb:39:in `make_and_send_pdf'
from /app/fa369291-829b-4b61-9efe-b2f0d0a0a42c/home/vendor/plugins/wicked_pdf/lib/pdf_helper.rb:13:in `render'
from /app/fa369291-829b-4b61-9efe-b2f0d0a0a42c/home/app/controllers/schedule_controller.rb:33:in `get_pdf'
Run Code Online (Sandbox Code Playgroud)
请帮忙.提前致谢.
编辑:
我在代码中做了一些更改并完成了这个错误,但仍然停留在这里
NoMethodError (undefined method empty? for #<Pathname:0x2b7112392480>)
pdf-generation ruby-on-rails heroku production-environment wicked-pdf
在我的rails应用程序中,子记录得到了marks_for_destruction我想撤消该操作并取消标记它们.有办法吗?
提前致谢.
I have three models, each having the following associations:
class Model1 < ActiveRecord::Base
has_many :model2s
has_many :model3s
end
class Model2 < ActiveRecord::Base
belongs_to :model1
has_many :model3s, :through => :model1 # will this work? is there any way around this?
end
class Model3 < ActiveRecord::Base
belongs_to :model1
has_many :model2s, :through => :model1 # will this work? is there any way around this?
end
Run Code Online (Sandbox Code Playgroud)
As you can see in the commented text, I have mentioned what I need.
我试图在我的一个分片集合中找到所有块的大小.
我想知道真正的 大小,而不是作为我知道我可以找到的设置的mongos提示:
use config
db.settings.find({_id : "chunksize"})
Run Code Online (Sandbox Code Playgroud)
我尝试了几种解决方案,但计数操作非常慢,所以这并不容易.你知道解决方案吗?(shell,csharp,python,ruby,bash,我不在乎)
现在我测试了以下内容:
db.getSisterDB("config").chunks.find({ns : "mydb.mycollection"}).forEach(function(chunk) {
db.getSisterDB("mydb").mycollection.find({},{_id : 0, partnerId , 1, id : 1}).min(chunk.min).max(chunk.max).count()
})
Run Code Online (Sandbox Code Playgroud)
但这太慢了,我的印象是它不使用我的分片键上的索引(打开{partnerId : 1, id : 1}).
我也用没有任何运气的解释取代了伯爵.我还用javascript forEach替换了count来手动计数(尝试使用不会命中磁盘的indexOnly查询).
我试图找到真正的大小,因为我已经看到几个块远远高于chunksize给出的提示(2Gb而不是64Mb).
I have a string as
classname = "Text"
Run Code Online (Sandbox Code Playgroud)
using this I want to create an object of the Text class
Now when I try doing this
classname = classname.constantize
Run Code Online (Sandbox Code Playgroud)
I get the Text as a module and not as a class. Please suggest something.
Thanks and regards
Rohit
这有效
irb(main):001:0> name = "Rohit " "Sharma"
=> "Rohit Sharma"
Run Code Online (Sandbox Code Playgroud)
但事实并非如此
irb(main):001:0> fname = "Rohit "
=> "Rohit "
irb(main):002:0> lname = "Sharma"
=> "Sharma"
irb(main):003:0> name = fname lname
Run Code Online (Sandbox Code Playgroud)
它给出了这个错误
NoMethodError: undefined method `fname' for main:Object
from (irb):3
Run Code Online (Sandbox Code Playgroud)
请提供一些建议.提前致谢.
UPDATE
得到答案后,我写了一篇博文.请检查一下.
我一直在使用rails 3进行一些开发,我想知道为什么调用"puts"方法不会输出到标准输出.
我怎么得到这个?
ruby ×6
string ×2
activerecord ×1
associations ×1
belongs-to ×1
destroy ×1
heroku ×1
installation ×1
ip ×1
ipv6 ×1
mongodb ×1
postgresql ×1
rubygems ×1
sharding ×1
wicked-pdf ×1