我正在使用SSH在远程服务器上启动后台进程.这就是我现在所拥有的:
ssh remote_user@server.com"nohup process&"
这是有效的,因为这个过程确实开始了.但是在我点击Ctr-C之前,SSH会话本身并没有结束.
当我点击Ctr-C时,远程进程继续在后台运行.
我想将ssh命令放在我可以在本地运行的脚本中,所以我希望ssh会话在远程进程启动后自动退出.
有没有办法让这种情况发生?
我有一个在Heroku上托管的Rails应用程序.该应用程序在Amazon S3上生成并存储PDF文件.用户可以下载这些文件以便在浏览器中查看或保存在他们的计算机上.
我遇到的问题是虽然可以通过S3 URL下载这些文件(如"https://s3.amazonaws.com/my-bucket/F4D8CESSDF.pdf"),但这显然不是一个好方法.它.不希望向用户公开关于后端的大量信息,更不用说上升的安全问题了.
是否有可能让我的应用以某种方式从控制器中的S3检索文件数据,然后为用户创建下载流,以便不暴露亚马逊URL?
我正在开发一个iPhone应用程序,在一个特定的视图中,我需要加载两个不同的实体:一个将填充一个UITableView,另一个将填充一个UITextView.
是否可以使用单个属性获取这两个属性NSFetchedResultsController?
或者我需要使用两种不同的NSFetchedResultsControllers?
关于如何最好地解决这个问题的任何想法?
在"显示"页面中有一些用于就地编辑模型的选项,即无需在"编辑"页面中加载表单.例如,请参阅http://www.ruby-toolbox.com/categories/rails_in_place_editing.html.
有没有人在Rails 3中使用任何这些选项(或其他)的经验?任何指针或建议?
就我而言,我有一个相当长的形式,由可变数量的项目组成.从可用性的角度来看,在同一页面中编辑这些项目中的文本是很有意义的,而不需要为将每个用户发送到特定项目的编辑页面的每个项目的编辑按钮.
我已经购买了SSL证书并将其安装到我的Heroku应用程序中.
但是,当我尝试通过https访问我的网站时,Chrome会报告:
本网站的身份尚未经过验证.•服务器的证书与URL不匹配.
其他浏览器报告类似的消息.
检查Chrome中的证书信息表明我的网站仍在使用由Digicert(而不是我自己的CA)发布的Heroku证书.
关于我可能遗失的任何想法?
我已经通过生成一个AJAX请求触发的动作Ajax.InPlaceEditor或者InPlaceCollectionEditor是这样的:
new Ajax.InPlaceCollectionEditor('agent_email', 'inspections/<%= @inspection.id %>/update_field',
{
collection: [<% @agents.each do |agent| %>
'<%= agent.email %>',
<% end %>],
okText: 'Update',
cancelText: 'Never mind',
savingText: 'Updating...'
});
Run Code Online (Sandbox Code Playgroud)
在另一端,该操作包含:
def update_field
--some code here--
if success
puts "stored change"
render :text => result
else
puts "did note change store"
render :text => inspection.errors.to_json, :status => 500
end
end
Run Code Online (Sandbox Code Playgroud)
一旦到达任何渲染方法,会话就会到期,并且下次用户发送请求时,Devise会将它们发送到登录页面.
即使我从update(before_filter :authenticate_user!, :except => :update_field)中免除update_field ,会话仍然会被重置.
我在Devise会话上看到了一个非常类似的问题的答案,它立即在.js调用[AJAX]上到期,但它并没有解决我的特定问题.
有任何想法吗?
我在Rails 3应用程序中使用RVM设置了PDFKit(必须手动复制wkhtmltopdf二进制文件).当我尝试渲染页面的PDF版本时,我收到此错误:
RuntimeError in AgenciesController#show command failed: ["lib/wkhtmltopdf/wkhtmltopdf", "--disable-smart-shrinking", "--page-size", "Letter", "--margin-top", "0.75in", "--margin-right", "0.75in", "--margin-bottom", "0.75in", "--margin-left", "0.75in", "--encoding", "UTF-8", "--quiet", "\n.......\n", "-"]
以下是我的应用程序.rb:
config.middleware.use "PDFKit::Middleware"
PDFKit.configure do |config|
config.wkhtmltopdf = 'lib/wkhtmltopdf/wkhtmltopdf'
end
想法为什么会这样?我该怎么解决?
在控制台中,我注意到了这条消息:
(sometimes it will work just to ignore this error with --ignore-load-errors)
我在哪里调用那个开关?wkhtmltopdf似乎在命令行上工作正常,我可以做类似"./wkhtmltopdf http://www.google.com google.pdf"的内容并生成PDF.
谢谢你的帮助,
彼得
我有一个包含嵌入文档的mongomapper文档,并希望复制它.
从本质上讲,我想要做的是这样的事情:
customer = Customer.find(params[:id])
new_customer = Customer.new
new_customer = customer
new_customer.save
Run Code Online (Sandbox Code Playgroud)
所以我想最终得到两个不同的mongomapper文档,但内容相同.
有什么想法应该怎么做?
我正在构建核心数据iphone应用程序,并且无法检索一对多的关系数据.我解释时请耐心等待.
我使用数据模型设计器来设置一个名为"Item"的实体,其中包含许多名为"Comment"的实体.然后我检索多个实体并将其显示在一个UITableView.我像这样获取这些实体(在viewDidLoad方法中):
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Items" inManagedObjectContext:self.managedObjectContext];
[request setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(Item_to_Areas.Name LIKE %@)",[areaManagedObject valueForKey:@"Name"]];
[request setPredicate:predicate];
[request setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObject:@"Item_to_item_comments"]];
NSLog(@"Results: %@", [mutableItemsFetchResults description]);
mutableItemsFetchResults = [[managedObjectContext executeFetchRequest:request error:nil] mutableCopy];
[request release];
Run Code Online (Sandbox Code Playgroud)
当用户点击一行时,我选择特定的entiny,在其init方法中将其传递给新的表视图控制器,并将新的视图控制器推送到堆栈:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"itemObject: %@", [mutableItemsFetchResults objectAtIndex:indexPath.row]);
InspectionItemCommentsViewController *itemCommentsViewController = [[InspectionItemCommentsViewController alloc]
initWithManagedObjectContext:self.managedObjectContext
itemObject:[mutableItemsFetchResults objectAtIndex:indexPath.row]];
itemCommentsViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:itemCommentsViewController animated:YES];
[itemCommentsViewController release];
}
Run Code Online (Sandbox Code Playgroud)
在第一个块中,NSLog输出显示检索到"Item_to_item_comments"关系实体,但在第二个块中,即使我调用了[request setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObject:@"Item_to_item_comments"]].
这是第一个NSLog输出的一部分:
Results: (
"<NSManagedObject: …Run Code Online (Sandbox Code Playgroud) 我有一个具有很多属性的模型,并构建了一系列页面来收集所有相关数据.在最后一页中,我想向用户显示所有收集的数据.
我可以通过手动键入每个属性的所有标签和值来创建此页面,但我希望这种繁琐和重复的任务已经由某人解决,以便在3-4行代码中.
在这个阶段,我只是原型设计,所以这不需要看起来很好.
任何人都有关于如何在屏幕上快速打印模型的所有属性的任何建议?
我在想这样的事情:
如果@my_data_model是我想要打印属性的实例变量,那么:
<%= show_attributes @my_data_model %>
Run Code Online (Sandbox Code Playgroud)
将使用其标签输出属性值.
谢谢你的期待.
我在Xcode组织器中收到此错误消息(以及随后的崩溃),我怀疑它与核心数据迁移有关,需要很长时间才能完成:
10月4日09:51:14未知SpringBoard [30]:appName未能及时发布
即使我插入人为延迟(例如,使用sleep(100)),此迁移也可在模拟器中找到.
只有当我尝试在iPhone 4或iPod第4代上进行测试时才会收到此超时错误消息.
如果不需要迁移,则通过在构建期间提供正确的sqlite3数据库版本,不会发生崩溃.
以下是代码中发生的事情:
在应用程序委托中:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
PropertiesTableViewController *propertiesTableViewController =
[[PropertiesTableViewController alloc] initWithManagedObjectContext:self.managedObjectContext];
UINavigationController *newNavController =
[[UINavigationController alloc]
initWithRootViewController:propertiesTableViewController];
[propertiesTableViewController release];
[window addSubview:newNavController.view];
NSLog(@"UUID: %@", [[UIDevice currentDevice] uniqueIdentifier]);
[window makeKeyAndVisible];
return YES;
}
- (NSManagedObjectContext *) managedObjectContext {
if (managedObjectContext != nil) {
return managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
managedObjectContext = [[NSManagedObjectContext alloc] init];
[managedObjectContext setPersistentStoreCoordinator: coordinator];
}
return managedObjectContext;
}`
Run Code Online (Sandbox Code Playgroud)
persistentStoreCoordinator是一个相当长的方法,很高兴在需要时提供它.它迁移两个数据库,每个数据库大约500kBytes.第一个总是成功,但第二个总是失败(在设备上),但两者总是在模拟器中成功.propertiesTableViewController提供了一个表视图,其中包含从迁移的数据库中获取的数据,因此必须在propertiesTableViewController查看之前进行迁移.
我还尝试使用以下方法尝试从propertiesTableViewController内部(在viewDidLoad方法中)触发迁移:
我的问题与此问题有关,但我试图反转"<%="的默认Rails 3行为,以便我可以注入HTML.
在我的场景中,我有一个生成HTML的旧Rails 2插件.然后我的视图需要在页面中注入此HTML.
当这个插件创建存储在变量中的HTML时html_to_show:
<p class="notice"><span></span>Sorry about this, but we have a problem...</p><p class="error"><span></span>Cannot go to next step</p>
Run Code Online (Sandbox Code Playgroud)
在视图中我试图显示这样的内容html_to_show:
<%= html_to_show %>
Run Code Online (Sandbox Code Playgroud)
...我在浏览器中得到的是:
<p class="notice"><span></span>Sorry about this, but we have a problem...</p><p class="error"><span></span>Cannot go to next step</p>
Run Code Online (Sandbox Code Playgroud)
如何让Rails 3 html_to_show完全按原样注入内容,而不进行任何清理?
core-data ×3
ajax ×2
cocoa ×2
amazon-s3 ×1
controller ×1
devise ×1
download ×1
entities ×1
erb ×1
fault ×1
helpers ×1
heroku ×1
ios ×1
linux ×1
model ×1
mongomapper ×1
nohup ×1
pdfkit ×1
relationship ×1
sanitization ×1
session ×1
ssh ×1
ssl ×1
wkhtmltopdf ×1