如何生成介于0和n之间的随机数?
如何生成介于0和n之间的随机数?
我使用的是Ruby on Rails 3.1预版本。我喜欢使用PostgreSQL,但问题是安装pg gem。它给了我以下错误:
$ gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/u/.rvm/rubies/ruby-1.9.2-p0/bin/ruby 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. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/u/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /home/u/.rvm/gems/ruby-1.9.2-p0/gems/pg-0.11.0 for inspection.
Results logged to /home/u/.rvm/gems/ruby-1.9.2-p0/gems/pg-0.11.0/ext/gem_make.out
我怎么解决这个问题?
我有一个迁移文件db\migrate\20100905201547_create_blocks.rb。
如何具体回滚该迁移文件?
什么是Rails中的真实性令牌?
我得到了错误:
FATAL: Peer authentication failed for user "postgres"
当我尝试让postgres与Rails一起工作时。
这是pg_hba.conf,我的数据库。Yml,以及完整跟踪的转储。
我在pg_hba中将身份验证更改为md5,并尝试了不同的方法,但似乎都不起作用。
我还尝试按照Rails 3.2创建一个新用户和数据库,FATAL: Peer authentication failed for user (PG::Error)
但是它们不会在pgadmin上显示,甚至当我运行sudo -u postgres psql -l时也不会显示。
知道我哪里错了吗?
如何在Ruby on Rails视图中获得当前的绝对URL ?
请求。request_uri只返回相对URL。
我是一名RoR初学者程序员,计划使用Heroku部署我的应用程序。我的其他顾问朋友说,Heroku真的很简单,很好用。唯一的问题是我仍然不知道赫鲁是做什么的…
我看了他们的网站,简而言之,Heroku所做的是帮助缩放,但是……这有什么关系呢?Heroku如何帮助:
速度——我的研究表明,如果我的目标受众是美国/亚洲,那么在美国东海岸部署AWS将是最快的。 安全性——他们有多安全? 缩放-它实际上是如何工作的? 成本效率——有一些像动态的东西,使其易于扩展。 他们在竞争对手面前表现如何?比如Engine Yard和bluebox?
请用外行的英语术语来解释……我是一个初级程序员。
我发现自己在反复寻找nil?,空白?空的?在Ruby on Rails中。这是我最接近的结果:
空白的吗?对象为false、空或空白字符串。例如,"","",nil,[],{}为空。 nil ?对象是NilClass的实例。 空的吗?对象是特定于类的,定义因类而异。如果字符串没有字符,则字符串为空;如果数组不包含项,则数组为空。
是否遗漏了什么,或者可以进行更紧密的比较?
我错误地将列命名为hased_password而不是hashed_password。
如何使用迁移重命名此列来更新数据库架构?