当我在开发模式下启动rails服务器时,我想要始终保持瘦身.
默认情况下,webrick使用.所以我在我的Gemfile中添加了thin
gem 'thin', :group => 'development'
Run Code Online (Sandbox Code Playgroud)
现在如果我想用它在开发模式下启动我的服务器,我必须定义它.
bundle exec rails s thin
Run Code Online (Sandbox Code Playgroud)
如果我没有定义它,它总是使用webrick.那么如何定义默认使用thin?
我与Handelbars的backbone.js应用程序执行以下操作.
代码如下.
(function ($)
{
// model for each article
var Article = Backbone.Model.extend({});
// collection for articles
var ArticleCollection = Backbone.Collection.extend({
model: Article
});
// view for listing articles
var ArticleListView = Backbone.View.extend({
el: $('#main'),
render: function(){
var js = JSON.parse(JSON.stringify(this.model.toJSON()));
var template = Handlebars.compile($("#articles_hb").html());
$(this.el).html(template(js[0]));
return this;
}
});
// main app
var ArticleApp = Backbone.Router.extend({
_index: null,
_articles: null,
// setup routes
routes: {
"" : "index"
},
index: function() {
this._index.render();
},
initialize: function() …Run Code Online (Sandbox Code Playgroud) 一旦你了解了轨道,我确信这很容易,但我是新手......
我想在按下提交按钮(f.submit)之后重定向到另一个页面/动作,并且仅在按下它之后.如何确定按下提交按钮后转到的链接?
以下是setup_mail.rb中Google Apps的smtp设置.
:address => "smtp.gmail.com",
:port => 587,
:domain => 'mysite.co',
:user_name => 'noreply@mysite.co',
:password => 'password',
:authentication => 'plain',
:enable_starttls_auto => true
Run Code Online (Sandbox Code Playgroud)
我的开发日志详细显示了生成的电子邮件并发送到正确的电子邮件地址......但它们没有到达.我只能认为上面的设置一定有问题.你能看出问题所在吗?
一旦解决了这个问题,我有什么问题可以让它在Heroku上运行吗?
注意:以上是记录弃用警告:
DEPRECATION WARNING: Giving a hash to body is deprecated, please use instance va
riables instead. (called from process at C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gem
s/actionmailer-3.0.0/lib/action_mailer/old_api.rb:77)
Run Code Online (Sandbox Code Playgroud) 我在运行黄瓜测试时遇到这个奇怪的错误:
ERROR Mongo::OperationFailure: Database command 'filemd5' failed: {"errmsg"=>"exception: best guess plan requested, but scan and order required: query: { files_id: ObjectId('4d1abab3a15c84139c00006e') } order: { files_id: 1, n: 1 } choices: { $natural: 1 } ", "code"=>13284, "ok"=>0.0}
Run Code Online (Sandbox Code Playgroud)
我有一个类似场景的列表,其中第一个场景通过,但所有其他后续场景都失败.我搜索了它,发现索引存在问题.但是,我不确定要写什么查询.此外,我可以在开发的mongo上添加查询.我想确保索引也在测试中完成.如果有人对此有任何想法,请随意.
我正在更改我的ruby gem以使其与资产管道兼容.在我的gemspec中,我想说它需要rails版本> 3.1和< 4.我怎么做.
目前这就是我所拥有的.
s.add_dependency("rails", ">= 3.1")
但这并不理想.这说明它也rails 4.0可能不适用.
我正在构建多租户应用程序.
所有数据隔离都由每个表中的TenantID列完成.
所有租户模型自动处理多租户的最佳方法是什么?
例:
Contacts.new({.....}) should automatically add :tenant => curret_user.tenant
Contacts.where({....}) should also add :tenant => curret_user.tenant
Run Code Online (Sandbox Code Playgroud)
目前我在CanCan gem中看到类似这样的内容,它可以获取特定用户参数的记录.但它没有为插入和更新操作提供任何东西.或者可能是我不明白该怎么做.
此致,Alexey Zakharov.
什么相当于relative_url_rootActionMailer?
我已尝试将其设置为default_url_options,但它会将参数附加到查询字符串中.
添加:skip_relative_url_root = false也不起作用.
使用:host = 'somehost.com/subdir' 确实有效,但这是否合适?
谢谢!
问候!
我一直在玩HAML并将一些视图转换.erb为.haml.但是当我试图转换.js.erb视图时,它就不会执行.例如,似乎我的工作本来应该.js.haml没有执行.js.erb.
这是我的.js.erb(也适用):
<% if @quote.errors.any? && @quote.approved? %>
$("#data_form").html("<%= escape_javascript(render(:partial => "form")) %>");
<% else %>
$("#data_grid").prepend("<%= escape_javascript(render :partial => "quote", :locals => { :quote => @quote }) %>");
$("#quote_author,#quote_body").each(function(i,e) {
$(this).val("");
});
<% end %>
Run Code Online (Sandbox Code Playgroud)
这就是我用它取而代之的:
-if @quote.errors.any? && @quote.approved?
$("#data_form").html("#{escape_javascript(render(:partial => "form"))}");
-else
$("#data_grid").prepend("#{escape_javascript(render :partial => "quote", :locals => { :quote => @quote })}");
$("#quote_author,#quote_body").each(function(i,e) {
$(this).val("");
});
Run Code Online (Sandbox Code Playgroud)
有什么问题以及如何解决?
在 Rails 3 中,当您执行 activeRecord.save 时是事务提交还是方法退出时?
所以我想弄清楚的是 MySQL 是否是在保存后立即编写的!或者在我退出定义黑色后保存
def something
1000.times do
o = Order.new(:name => "Tomas")
o.save
end
end
Run Code Online (Sandbox Code Playgroud) actionmailer ×2
javascript ×2
backbone.js ×1
cancan ×1
cucumber ×1
devise ×1
haml ×1
heroku ×1
mongoid ×1
multi-tenant ×1
ruby ×1
rubygems ×1
smtp ×1
submit ×1