我想使用Textmate提高我的Rails编码效率.显然,快捷方式(无论是Textmate还是Mac)都可以提供很大的帮助.哪些快捷方式可以为您的开发提供最大的帮助?
对于现有应用程序的rails CSS框架,您更喜欢哪一个 - LESS或COMPASS?
假设我有以下spec子目录:
lib
models
observers
workers
Run Code Online (Sandbox Code Playgroud)
在spec_helper.rb文件中,如何告诉rspec排除lib子目录中的所有spec文件?
Spork.prefork do
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
DatabaseCleaner.strategy = :transaction
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
end
end
Spork.each_run do
FactoryGirl.reload
end
Run Code Online (Sandbox Code Playgroud)
仅供参考 - 我正在使用防护来自动重新加载测试。
在这个Q&A线程之后,我得到了它,以便用户可以使用弹出窗口通过Omniauth Facebook策略登录.这是我的代码:
视图:
<%= link_to("Sign in with Facebook", "/auth/facebook", :id => "signin",
:data => {:width => 600, :height => 400}) %>
Run Code Online (Sandbox Code Playgroud)
application.js中:
function popupCenter(url, width, height, name) {
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
return window.open(url, name, "menubar=no,toolbar=no,status=no,width="+width+",height="+height+",toolbar=no,left="+left+",top="+top);
}
$(document).ready(function() {
$('a#signin').click(function(e) {
popupCenter($(this).attr('href'), $(this).attr('data-width'), $(this).attr('data-height'), 'authPopup');
e.stopPropagation();
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
sessions_controller.rb:
def create
user = AuthProviders::FacebookUser.find_or_create_user_from(auth_hash)
session[:current_user_id] = user.id
@return_to = origin || root_url
render :callback, :layout => false
end
protected
def auth_hash
request.env['omniauth.auth'] …Run Code Online (Sandbox Code Playgroud) 我遇到了使用Travis CI自动部署到我的Phoenix应用程序的Heroku的问题.这是Travis CI构建错误:
(Mix) The database for AgilePulse.Repo couldn't be created: tcp connect: connection refused - :econnrefused
Run Code Online (Sandbox Code Playgroud)
这是我的.travis.yml配置:
language: elixir
elixir:
- 1.3.2
otp_release:
- 19.0
sudo: false
addons:
postgresql: '9.5'
notifications:
email: false
env:
- MIX_ENV=test
before_script:
- cp config/travis_ci_test.exs config/test.secret.exs
- mix do ecto.create, ecto.migrate
Run Code Online (Sandbox Code Playgroud)
这是我的travis_ci_test.exs:
use Mix.Config
# Configure your database
config :agile_pulse, AgilePulse.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "",
database: "travis_ci_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
Run Code Online (Sandbox Code Playgroud)
任何指针将不胜感激!
附加信息:
Tue, 16 Feb 2010 03:12:02 UTC +00:00例如,我有一个UTC日期.变量a,b,c和d都需要设置为'foo'.
有没有办法在一次俯冲任务中完成这项任务?喜欢:
a,b,c,d ='foo'
我在表中有一个字符串列,可以有一系列预定义的值.它还可以包含零值.例如:狗,猫,鸟,零.
我想编写一个validates_inclusion_of来检查以确保输入的所有值都在该预定义范围内.如果输入"鼻腔喷雾",则会产生错误.
最好的方法是什么?
让我们假设我有一个用户创建主题并在Fruit上编写主题的网站.
为了让用户了解整个网络上的所有Fruit对话,我收集与特定主题相关的推文,并根据推文的内容创建线程.
显然,推文与主题相关非常重要.假设用户创建了一个名为Apples和Oranges的主题.我拉所有包含关键词Apples和/或Oranges的推文.
我遇到的问题是,一些Twitter用户编写了一条推文,其中包含关键词Apples,Oranges,Pears等,并将其收集并作为线程发布到Apples和Oranges讨论主题.这让用户生气!
所以我需要的是一种过滤任何包含苹果和/或橘子以外的水果单词的推文的方法.
例如,如果Twitter用户写"我喜欢苹果,橘子,梨和葡萄",那么不应该包含该推文.
现在,您只能使Twitter搜索查询如此复杂.因此,在收集推文后,必须在Ruby中执行排除逻辑.
以编程方式,你将如何解决这个问题?
我知道有关此主题的类似问题已被提出,但看起来并不是一个明确的解决方案.所以,这是我的小提琴:
我想垂直分割"Pick"标题下的表格单元格.如果可能的话,我更喜欢不需要JS或任何东西的解决方案.