我运行捆绑更新来更新我的宝石.现在,当我尝试启动本地开发服务器时,我得到了这个.谁知道如何解决?
hostname:myapp username$ rails s
/Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:238:in `activate': can't activate i18n (~> 0.4.1, runtime) for ["mail-2.2.10", "actionmailer-3.0.3", "rails-3.0.3"], already activated i18n-0.5.0 for ["activemodel-3.0.3", "actionpack-3.0.3", "rails-3.0.3"] (Gem::LoadError)
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:254:in `block in activate'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:253:in `each'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:253:in `activate'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:254:in `block in activate'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:253:in `each'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:253:in `activate'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:254:in `block in activate'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:253:in `each'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:253:in `activate'
from /Users/username/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:1065:in `gem'
from /Users/username/.rvm/gems/ruby-1.9.2-p0@rails3/bin/rails:18:in `<main>'
Run Code Online (Sandbox Code Playgroud) 我想改变我的NSNumberformatter从显示带有括号的负数到将减号放在前面(或者无论本地标准是什么).
我想我可以用setNegativeFormat做到这一点:
但阅读Apple的哦,如此彻底的文档,我只是在摸不着头脑:
setNegativeFormat:
设置接收器用于显示负值的格式.
- (void)setNegativeFormat:(NSString *)aFormat
Run Code Online (Sandbox Code Playgroud)
参数 aFormat一个字符串,指定负值的格式.
可用性适用 于iPhone OS 2.0及更高版本.
另请参阅 - negativeFormat
在 NSNumberFormatter.h中声明
我对aFormat有什么选择?!?来自Doc Docrs,这里的链接会杀了你吗?
编辑:这里有什么值得宣言:
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
Run Code Online (Sandbox Code Playgroud)
对我来说,保留本地化的货币符号和小数位是很重要的.因此,[currencyFormatter setNegativeFormat:@" - #,## 0.00"]可能无法正常工作,因为货币缺失,并且不能为所有货币假设2位小数.
当我正在使用Rails并开发视图时,我经常想要注释掉代码.类和模型足够简单,但视图有点棘手.
什么是在视图中对代码进行注释的最佳方式,因此它不会被任何东西解释...... HTML给出了我们,<!-- commented Rails code here -->虽然这里附带的代码似乎得到了解释?!?还是有更多的Railsy方式?
因此,Ruby 有时候使用大括号而不是要求它们的宽松容忍度导致了很多混乱,因为我正在尝试学习Rails以及何时/何地使用它们以及为什么?
有时参数或值会像(@user, @comment)它们看起来那样传递,而其他时候传递[ :user => comment ]的只是::action => 'edit'
我在谈论[] vs () vs {}的我们
规则是什么?你有什么技巧可以帮助你记住吗?
我正在开始一个新的应用程序,并注意到我上次从头开始构建MongoID应用程序时缺少一些文档.也就是说,他们曾经在不再存在的页面上建议(http://mongoid.org/docs/integration/)包含一些代码来删除MongoID的集合(在测试之后).
它现在不再被提及了... 这是(下面的****)不再被视为必要或良好的做法?!?
#spec/spec_helper.rb:
...
RSpec.configure do |config|
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
#config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
#config.use_transactional_fixtures = true
# Below from <http://mongoid.org/docs/integration/> ****
config.after :suite do
Mongoid.master.collections.select do |collection|
collection.name !~ /system/
end.each(&:drop)
end
end
Run Code Online (Sandbox Code Playgroud) 考虑在新机器上投入RVM(轻型).但是我没有想象如果用户没有登录它将如何工作.已经安装了RVM,/usr/local/rvm/bin/rvm因此它可供"所有人"使用.
如果服务器重新启动并且在登录屏幕并且后台守护进程正在服务apache/rails等等而且没有.bashrc,等等已经加载...我们如何/在哪里指定要加载哪些RVM的Rubies?
也许在Phusion的乘客的某个地方?
谁管理这些宝石?他们分享了吗?
可能重复:
使用Rails完全自定义验证错误消息
我正在玩Rails 3.1rc1并认为SecurePassword对我有用.但是,我不喜欢默认的错误消息Password digest can't be blank.如果我打电话给validates_presence_of :password_digest自己我可以通过:message => "Password can't be blank"但是因为它在框架中我不知道如何覆盖消息以删除"digest"这个词只会混淆joe用户.有人知道怎么做吗?
编辑:
尝试添加'覆盖':validates_presence_of像这样:
class User < ActiveRecord::Base
attr_accessible :email, :password
has_secure_password
validates_presence_of :password_digest, :message => "Password can't be blank"
end
Run Code Online (Sandbox Code Playgroud)
但是当尝试提交一个空白密码时,你只会得到两倍的错误:
表格无效
我认为有一种方法可以快速要求NSSet其对其成员进行轮询,并NSInteger在每个对象中返回一个说明属性的总和,但我可能会将此与Mac OS X方面的内容混淆.这在Cococa Touch中是否存在?
我能找到的最接近的东西是objectEnumerator,我想我可以通过每个对象来增加我自己的变量.更好的方式存在吗?
希望有人可能会看到我忽略的东西......
我试图让Capybara在一个现有的小应用程序中工作......而且我没有运气.
的Gemfile:
group :development, :test do
gem 'rspec-rails'
# gem 'webrat'
gem 'capybara', :git => 'git://github.com/jnicklas/capybara.git'
end
...
Run Code Online (Sandbox Code Playgroud)
两个地方的类似规格因各种原因而失败.不知道为什么?
规格/控制器/ pages_controller_spec.rb:
require 'spec_helper'
describe PagesController do
describe "GET 'about'" do
it "should be successful" do
# get 'about' #worked w/ webrat
# response.should be_success #worked w/ webrat
visit pages_about_path
# page.should have_content('About Us')
page.html.should match(/About/i)
end
it "should have title" do
# get 'about' #webrat
# response.should have_selector("title", :content => "About Us") #webrat
visit pages_about_path
page.should have_selector("title")
end
end …Run Code Online (Sandbox Code Playgroud) 我无法在Rails应用程序中使用Elasticsearch(和Tire)进行突出显示.我可以成功索引PDF附件并查询它们但我无法突出显示工作.
不熟悉ES所以不确定在哪里进行故障排除.将从映射和卷曲查询开始,但随时可以要求更多信息.
class Article < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
attr_accessible :title, :content, :published_on, :filename
mapping do
indexes :id, :type =>'integer'
indexes :title
indexes :content
indexes :published_on, :type => 'date'
indexes :attachment, :type => 'attachment',
:fields => {
:name => { :store => 'yes' },
:content => { :store => 'yes' },
:title => { :store => 'yes' },
:file => { :term_vector => 'with_positions_offsets', :store => 'yes' },
:date => { :store => 'yes' }
}
end
def to_indexed_json …Run Code Online (Sandbox Code Playgroud) cocoa-touch ×2
rspec ×2
bundler ×1
capybara ×1
cocoa ×1
collections ×1
comments ×1
curly-braces ×1
erb ×1
erubis ×1
jrubyonrails ×1
mongoid ×1
nsset ×1
objective-c ×1
parentheses ×1
passenger ×1
ruby ×1
rubygems ×1
rvm ×1
tire ×1
validation ×1