我升级到RoR 3.0.1和Ruby升级到1.9.2. 现在我视图中的所有字符串都是ASCII-8BIT?
我相信我的应用程序设置为使用UTF 8
application.rb中
config.encoding = "utf-8"
Run Code Online (Sandbox Code Playgroud)
database.yml的
development:
adapter: mysql
encoding: utf8
Run Code Online (Sandbox Code Playgroud)
我在跑
OS X
RVM rvm 1.0.16
Ruby ruby-1.9.2-p0
Rails 3.0.1
Run Code Online (Sandbox Code Playgroud)
我希望编码是UTF 8而不是ASCII
business.desc.encoding
# ASCII-8BIT
Run Code Online (Sandbox Code Playgroud)
由于1.9.x可以连接不同编码的字符串,我们会看到很多这样的错误.
<p class="description"><%= truncate(business.desc, :length => 17) %></p>
Run Code Online (Sandbox Code Playgroud)
错误
incompatible character encodings: ASCII-8BIT and UTF-8
activesupport (3.0.1) lib/active_support/core_ext/string/output_safety.rb:74:in `concat'
activesupport (3.0.1) lib/active_support/core_ext/string/output_safety.rb:74:in `concat'
actionpack (3.0.1) lib/action_view/template/handlers/erb.rb:14:in `<<'
app/views/browse/businesses.html.erb:15:in `block in _app_views_browse_businesses_html_erb___1616718260917998189_2173630500__1134905695726531092'
app/views/browse/businesses.html.erb:3:in `each'
app/views/browse/businesses.html.erb:3:in `each_with_index'
app/views/browse/businesses.html.erb:3:in `_app_views_browse_businesses_html_erb___1616718260917998189_2173630500__1134905695726531092'
Run Code Online (Sandbox Code Playgroud)
还有其他人有这个问题吗?ruby-1.9.2-p0是否使用正确的版本?
谢谢!
自从我开始使用rvm以来,我度过了一段艰难的时光.我已经完成了所有的rvm/textmate设置并拥有最新的捆绑包但我仍然无法从textmate运行Rspec测试.
我有最新的捆绑包github.com/rspec/rspec-tmbundle.git
,它安装在~/Library/Application\ Support/TextMate/Bundles/
RSpec.tmbundle
RVM默认使用系统ruby 1.8.6
Rspec宝石版本
宝石列表 - 本地| grep spec blue_light_special(0.2.0)rspec(2.2.0)rspec-core(2.2.1,2.0.1)rspec-expectations(2.2.0,2.0.1)rspec-mocks(2.2.0,2.0.1) rspec-rails(2.0.1,1.3.2)
TextMate的
TM_RUBY = /用户/ jspooner/.rvm /斌/ RVM-自动红宝石
错误:rspec/core(LoadError)
/ Users/jspooner/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/rspec/mate.rb:29:in require': no such file to load -- rspec/core (LoadError) from /Users/jspooner/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/rspec/mate.rb:29 from /tmp/textmate-command-8073.rb:2:inrequire'from /tmp/textmate-command-8073.rb:2
我有一个模型,成员将能够更新,但他们的更改将不会生效,直到管理员批准他们的更改.有没有人解决过同样的问题,你会推荐哪些宝石进行版本控制?PaperTrail?Vestal版本?
如果allowfullscreen param为false,我想删除全屏按钮.
param value="true" name="allowfullscreen"
有谁知道它是否有可能检测到这个值?它没有与loaderInfo.parameters上的其他flashvars一起提供.
所以我为一个练习模型创建了一些rspec_scaffold并将"map.resource:exercises"添加到我的路径文件中,当"/ exercise"url呈现show动作时我感到很惊讶.有没有搞错?为什么不渲染索引动作?
耙路线
new_exercises GET /exercises/new(.:format) {:controller=>"exercises", :action=>"new"}
edit_exercises GET /exercises/edit(.:format) {:controller=>"exercises", :action=>"edit"}
exercises GET /exercises(.:format) {:controller=>"exercises", :action=>"show"}
PUT /exercises(.:format) {:controller=>"exercises", :action=>"update"}
DELETE /exercises(.:format) {:controller=>"exercises", :action=>"destroy"}
POST /exercises(.:format) {:controller=>"exercises", :action=>"create"}
Run Code Online (Sandbox Code Playgroud) 我更新到Rails 2.3.10,Rack 1.2.1,现在我的flash消息都没有出现.我发现在重定向期间,通知会像这样传递
redirect_to(@user, :notice => "Sorry there was an error")
Run Code Online (Sandbox Code Playgroud)
在我看来,flash哈希是空的
<%= debug flash %>
!map:ActionController::Flash::FlashHash {}
Run Code Online (Sandbox Code Playgroud)
但是您可以在控制器中看到该消息. 是什么赋予了?
<%= debug controller.session %>
session{:home_zip=>"94108", :session_id=>"xxx", :flash=>{:notice=>"Sorry there was an error"}, :user_credentials=>"1baf9c9c0423ce0151ec32e24cc422f07309e4ba503eb4830635ecc115da217809997324374bb273b3fb792895c9741a8b8c9ea4267771a1bd149de5b9179ea0", :user_credentials_id=>22, :home_market_id=>11}
Edit Profile
Run Code Online (Sandbox Code Playgroud) 我在我的iPhone应用程序中使用RestKit来加载国家列表.问题是elementToPropertyMappings方法使用字典来映射每个对象.在我的情况下,我有一个字符串数组,我想映射到我的Country类的name属性.
有人知道怎么做吗?
elementToPropertyMappings
必须返回包含从JSON元素名称到属性访问器的映射的字典
- (NSDictionary*)elementToPropertyMappings在RKObjectMappable.h中声明
我的JSON数据
["Argentina","Australia","Austria","Belgium","Bolivia","Brazil","Bulgaria","Canada","Cayman Islands","China","Costa Rica","Croatia","Czech Republic","Denmark","Ecuador","Ethiopia","F.Y.R.O. Macedonia","Finland","France","French Polynesia","Germany","Guam","Hong Kong SAR","Indonesia","Ireland","Israel","Italy","Japan","Latvia","Lithuania","Luxembourg","Malaysia","Malta","Mexico","Morocco","Netherlands","New Zealand","Nicaragua","Norway","Papua New Guinea","Peru","Poland","Portugal","Puerto Rico","Qatar","Romania","Russia","Singapore","Slovakia","Slovenia","South Africa","South Korea","Spain","Sweden","Switzerland","Taiwan","United Arab Emirates","United Kingdom","United States","Venezuela","Vietnam"]
Run Code Online (Sandbox Code Playgroud)
更新:
我想出了如何使用RKClient发出请求,以便跳过映射功能.现在我需要弄清楚用于JSON解析的类.yajl-objc解析器看起来很棒,但如果可以使用RestKit中的lib完成,我不想包含另一个解析器.
-(void)loadLocations
{
NSLog(@"loadLocations");
RKObjectManager *objectManager = [RKObjectManager sharedManager];
[[RKClient sharedClient] get:@"/locations/countries.json" delegate:self];
}
- (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response {
NSLog(@"Loaded payload: %@", [response bodyAsString]);
// HOW CAN I PARSE THIS STRING INTO AN NSArray?
}
Run Code Online (Sandbox Code Playgroud) ActiveRecord::Base.include_root_in_json = true 似乎没有在rails 3.10.rc4中工作,我在文档中看不到它.
由于根元素现在默认关闭,我们如何重新启用它?
@comments.to_json 在rails 3.1现在看起来像
[
{
comment: "Fun street park.",
created_at: 2011-06-29T02:28:29Z,
}
]
Run Code Online (Sandbox Code Playgroud)
在以前的版本中,它有根节点,我需要回来.
[
{
comment: {
comment: "Fun street park.",
created_at: 2011-06-29T02:28:29Z
}
}
]
Run Code Online (Sandbox Code Playgroud) 有没有办法创造一个简单的守卫手表?我希望在特定目录中的文件发生更改时运行rake任务,并且执行所有这些步骤对于这一个关闭任务来说太多了. https://github.com/guard/guard/wiki/Create-a-guard
我尝试在Guardfile中添加它,但它不起作用.
guard :doc do
watch(%r{^documentation}) { "rake doc:build" }
end
watch("/documentation") { "rake doc:build" }
Run Code Online (Sandbox Code Playgroud)
那么,当您使用guard更新文件时,您是否知道运行rake任务的简单方法?
新的谷歌地图SDK for iOS现在有一个用于显示指南针的UI小部件.唯一的问题是我只看到打开或关闭它的方法.你知道是否有可能改变它在地图上的位置?
https://developers.google.com/maps/documentation/ios/map#compass