我正在使用rails 3和黄瓜,除了这个小问题外,一切顺利
Given I am on the "edit automobile" page
No route matches {:controller=>"automobiles", :action=>"edit"} (ActionController::RoutingError)
Run Code Online (Sandbox Code Playgroud)
现在路径在paths.rb中设置为edit_automobile_path
在routes.rb我有汽车作为资源,我搭建了它
所以请告诉我我错过了什么,显然路线是定义和匹配的,因为我跑了耙路线并看到了路线.
请指出我正确的方向
什么会导致错误返回null,这就是我所拥有的
+ (BOOL)saveContext:(NSManagedObjectContext *)context
{
NSError *error = nil;
if (![context save:&error])
{
DLog(@"ERROR %@, %@", error, [error userInfo]);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry"
message:@"Error Saving the Data"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
return NO;
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
上面的方法是一个类方法,我不知道为什么错误没有任何信息.
这个方法就是这样调用的
[HSCoreDataUtility saveContext:self.managedObjectContext];
当一个modalViewController关闭并返回到NavigationController时,所以我需要保存上下文,但它通过一个错误,现在我想我已经知道它没有被保存的原因,但不应该错误给出我有一个线索?但是日志只是说"ERROR(null),(null)"
有什么想法吗
我正在尝试创建一个rails模板,它将代码添加到特定行号的文件中.例如,我需要添加一个到config/routes.rb的路由
我试过sed,gsed(只是因为我在mac上他们说sed有插入和追加问题),无论如何,我无法达到我想要的结果.
任何有关这方面的帮助将不胜感激.
我已尝试过几个这个命令的排列,但没有一个工作,这是一个例子
run "gsed '3 a/This is it' config/routes.rb"
Run Code Online (Sandbox Code Playgroud)
也许甚至是另一个建议
编辑::::::
好,我休息了一下,当我回来的时候,在SED读了之后,我意识到我需要到流写回文件,但我之前这样做,
run "gsed '2 a\
Add this line after 2nd line
' config/routes.rb > config/routes.rb"
Run Code Online (Sandbox Code Playgroud)
但路由文件是空白的,所以我尝试使用不同的文件名(new.routes.rb),
run "gsed '2 a\
Add this line after 2nd line
' config/routes.rb > config/new.routes.rb"
Run Code Online (Sandbox Code Playgroud)
这很有用,所以我知道现在要做什么.