当我从终端启动MongoDB服务器(mongod)时,它会保持该选项卡打开.我如何将其作为服务运行?
我在OSX Lion上.
我喜欢rails服务器脚本如何使用-d选项将其从终端分离.
我在生产服务器上遇到了这个错误,无法找出原因.它在运行此命令时发生:
bundle exec rake assets:precompile RAILS_ENV=production
Run Code Online (Sandbox Code Playgroud)
我正在使用Rails 3.1.0.rc6
production ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 asset-pipeline
在Rails中有与PHP相同的东西die()吗?
我有一个案例,它可以使我的控制器代码更清洁一些,有时会调用渲染两次,除非有一个die().
我正在制作专辑查看器.在顶部我想要一个所有图像缩略图的水平容器.现在所有的缩略图都包含在div中float:left.我试图找出如何在太多时将这些缩略图保持包裹到下一行,而是将所有缩略图保留在一个水平行中并使用滚动条.
这是我的代码:(我不想使用表格)
<style type="text/css">
div {
overflow:hidden;
}
#frame {
width:600px;
padding:8px;
border:1px solid black;
}
#thumbnails_container {
height:75px;
border:1px solid black;
padding:4px;
overflow-x:scroll;
}
.thumbnail {
border:1px solid black;
margin-right:4px;
width:100px; height:75px;
float:left;
}
.thumbnail img {
width:100px; height:75px;
}
#current_image_container img {
width:600px;
}
</style>
<div id="frame">
<div id="thumbnails_container">
<div class="thumbnail"><img src="http://www.blueridgexotics.com/images/glry-pixie-bob-kittens.jpg" alt="foo" /></div>
<div class="thumbnail"><img src="http://www.blueridgexotics.com/images/PB-KitJan08-1.jpg" alt="foo" /></div>
<div class="thumbnail"><img src="http://www.blueridgexotics.com/images/PB-KitJan08-3.jpg" alt="foo" /></div>
<div class="thumbnail"><img src="http://www.blueridgexotics.com/images/PB-Jan08.jpg" alt="foo" /></div>
<div class="thumbnail"><img src="http://www.blueridgexotics.com/images/gallery3.jpg" alt="foo" /></div>
<div class="thumbnail"><img …Run Code Online (Sandbox Code Playgroud) 我不喜欢rails默认使用页面标题的方式(只使用控制器名称),所以我正在研究一种新的方式:
应用控制器:
def page_title
"Default Title Here"
end
Run Code Online (Sandbox Code Playgroud)
帖子控制器:
def page_title
"Awesome Posts"
end
Run Code Online (Sandbox Code Playgroud)
应用布局:
<title><%=controller.page_title%></title>
Run Code Online (Sandbox Code Playgroud)
它运行良好,因为如果我在当前使用的任何控制器中没有page_title方法,它将回退到应用程序控制器中的默认值.但是,如果在我的用户控制器中我希望它返回"注册"以进行"新"操作,但是可以退回到其他任何操作?有没有办法做到这一点?
其次,还有其他人有任何其他方式在rails中进行页面标题吗?
尝试在生产模式下本地启动Rails 3.1应用程序.
rails s
Run Code Online (Sandbox Code Playgroud)
将启动进入开发就好了.当我尝试
rails s production
Run Code Online (Sandbox Code Playgroud)
我收到错误:
/usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rack-1.3.4/lib/rack/handler.rb:63:in
`require': no such file to load -- rack/handler/production (LoadError)
from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rack-1.3.4/lib/rack/handler.rb:63:in `try_require'
Run Code Online (Sandbox Code Playgroud) environment ruby-on-rails production-environment ruby-on-rails-3
作为Web开发人员,我经常在另一个(父)div中有两个浮动(子)div.其实我整天都这样做.
<style type="text/css">
#left {float:left;}
#right {float:right;}
</style>
<div id="parent">
<div id="left" class="child"> </div>
<div id="right" class="child"> </div>
</div>
Run Code Online (Sandbox Code Playgroud)
如果没有额外的css/html,这不起作用,因为父级不会自动增长以适应浮动的子级.有两种流行的方法可以克服:
1)添加overflow:hidden到父母的CSS.
2)添加第3个"清除"孩子<br style="clear:both;" />.
我知道还有一些关于这类事情的类似问题,但我的问题是:
哪种方法更好,为什么?各自的优点和缺点是什么?
我刚刚创建的rails模型出现了一个奇怪的问题.
以下是我的验证:
validates_presence_of :from_name, :message => 'Please provide a from name.'
validates_presence_of :from_email
validates_presence_of :giftition_plan_id
Run Code Online (Sandbox Code Playgroud)
我在使用errors.full_messages和使用时遇到了问题f.error_messages:
g = Giftition.create
g.errors.first
=> ["from_name", "Please provide a from name."]
>> g.errors.full_messages
=> ["{{attribute}} {{message}}", "{{attribute}} {{message}}", "{{attribute}} {{message}}"]
Run Code Online (Sandbox Code Playgroud)
我刚刚开始"{{attribute}} {{message}}".有任何想法吗?
更新:我已经卸载了rails 3以及随之安装的所有gem,这使问题消失了.虽然这不是一个修复...我仍然希望安装rails 3.
更新:听起来像升级到2.3.9修复了问题.不幸的是,我现在已经放弃了,但将来的某个时候我会尝试.
ruby validation activerecord ruby-on-rails internationalization
所以我刚刚为我的rails应用程序更改了密码表单.它就像任何其他非常典型的密码更改表单一样.
所以经过几次测试后我开始看到一个弹出框说
"Please confirm which user you are changing the password for"
现在这真的吓坏了我,因为我知道我没有写任何代码来做这些事情,我绝对不希望用户更改其他用户的密码.
我很快发现它是firefox的密码管理器.所以现在我对它很平静,但是,我仍然不希望这发生在使用我网站的其他人身上.
firefox如何知道它正在改变密码?也许这是我的密码字段的名称,甚至可能是我的表格动作网址(/ account/change_password)?有没有办法让它不这样做?有没有其他人有这方面的经验?
在我的应用程序中,只有管理员可以创建新的用户记录.用户通过电子邮件发送激活链接,在其中设置密码.
我想使用has_secure_passord方法(railscast):
class User < ActiveRecord::Base
has_secure_password
...
end
Run Code Online (Sandbox Code Playgroud)
效果很好,但它会自动验证密码摘要的存在...所以当管理员创建记录时,验证失败.我有办法跳过自动添加的password_digest验证而不跳过我添加的其他人吗?
css ×2
html ×2
ruby ×2
validation ×2
activerecord ×1
environment ×1
erb ×1
firefox ×1
formatting ×1
forms ×1
layout ×1
mongodb ×1
passwords ×1
php ×1
production ×1
service ×1
syntax ×1
title ×1