我正在为我的应用做一个报告系统.我创建了一个模型ReportKind,但是由于我可以报告很多东西,我想制作不同类型的报告类型.由于他们共享很多行为,我正在尝试使用继承.
所以我有主要模型:
model ReportKind << ActiveRecord::Base
end
Run Code Online (Sandbox Code Playgroud)
并创建了例如:
model UserReportKind << ReportKind
end
Run Code Online (Sandbox Code Playgroud)
在我的表report_kinds中,我是类型列,直到这里它的全部工作.我的问题在于表单/控制器.
当我这样做时ReportKind.new,我的表单是使用'*report_kind*'前缀构建的.如果获得UserReportKind,即使通过a ReportKind.find,表单也会构建'user_report_kind'前缀.
这会使控制器中的所有内容变得混乱,因为有时候我会有params [:report_kind],有时候是params [:user_report_kind],等等我所做的每一个其他继承.
无论如何强迫它使用'report_kind'前缀?此外,我不得不强制控制器中的属性'type',因为它没有直接从表单中获取值,是否有一个很好的方法来做到这一点?
路由是另一个问题,因为它试图基于继承的模型名称构建路由.我通过在指向同一控制器的路由中添加其他模型来克服这个问题.
forms inheritance activerecord ruby-on-rails ruby-on-rails-3
这是Mac/OSX相关的问题!
我有以下三个字符长haskell字符串:
"a\160b"
Run Code Online (Sandbox Code Playgroud)
我想匹配并替换中间字符
几种方法就像
ghci> :m +Text.Regex
ghci> subRegex (mkRegex "\160") "a\160b" "X"
"*** Exception: user error (Text.Regex.Posix.String died: (ReturnCode 17,"illegal byte sequence"))
ghci> subRegex (mkRegex "\\160") "a\160b" "X"
"a\160b"
Run Code Online (Sandbox Code Playgroud)
没有产生预期的结果.
如何修改正则表达式或我的环境以将'\ 160'替换为'X'?
问题似乎是它在输入的语言环境/编码中的根源.
bash> locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
Run Code Online (Sandbox Code Playgroud)
我已经修改了我的.bashrc以导出以下env-vars:
bash> locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
Run Code Online (Sandbox Code Playgroud)
但这并没有改变这种行为.
我试图在virtualenv中运行Openblock,但问题是Openblock需要Django 1.2.5并且我已经在服务器上安装了Django 1.1.1.
$ python -c "import django;print django.get_version()" 返回1.1.1
激活virtualenv后,相同的命令返回1.2.5.到现在为止还挺好.
但是当我yolk -l在virtualenv中运行时,它显示1.1.1为活动,1.2.5为非活动.
如何获取ALAssets数组中每个项目的路径?
我想获取图像,以便我可以将它们添加到电子邮件中
例如
NSString *path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailViewController addAttachmentData:myData mimeType:@"image/png" fileName:@"sample"];
Run Code Online (Sandbox Code Playgroud)
如何才能做到这一点?
我有一个视图,将新视图推送到屏幕上.
显示新视图时,导航控制器中没有后退按钮.
我在一个视图中有以下内容
然后使用以下代码推送新视图
[photoViewController setAsset:[assets objectAtIndex:(cell.rowNumber * 4) + index]];
[[self navigationController] pushViewController:photoViewController animated:YES];
[photoViewController release];
Run Code Online (Sandbox Code Playgroud)
当视图出现时,可以看到以下内容

如何添加后退按钮以及在第二个视图中将相同的共享按钮添加到栏的位置?
谢谢.:)
为什么QueryInterface()呼叫总是跟着Release()呼叫?例如,我看过MSDN的示例代码如下:
HRESULT hr = S_OK;
CDecoder *pObj = new CDecoder(&hr);
if (SUCCEEDED(hr))
{
*ppv = NULL;
hr = pObj->QueryInterface(riid, ppv);
}
pObj->Release();
return hr;
Run Code Online (Sandbox Code Playgroud)
有人可以解释Release()这里打电话的意图吗?
我有一个包含一堆Points(带有X和Y组件)的列表.
我想获得列表中所有点的Max X,如下所示:
double max = pointList.Max(p=> p.X);
Run Code Online (Sandbox Code Playgroud)
问题是当我在列表中有一个null而不是一个点.解决这个问题的最佳方法是什么?
我正在研究Orange,并且在 OSX (10.6.5) 中,菜单栏名称是“Python”而不是橙色,我得到了这个 nit。这是一个 python/qt 应用程序。我需要改变什么?
澄清:
我的信息.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>YOORANGE</string>
<key>CFBundleExecutable</key>
<string>Orange</string>
<key>CFBundleIconFile</key>
<string>orange.icns</string>
<key>CFBundleIdentifier</key>
<string>si.ailab.Orange</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Orange</string>
<key>CFBundleGetInfoString</key>
<string>Orange, component-based data mining software</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>Orng</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>ows</string>
</array>
<key>CFBundleTypeName</key>
<string>Orange Canvas Schema</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>OWSf</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>schema.icns</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSIsAppleDefaultForType</key>
<true/>
</dict>
</array>
</dict> …Run Code Online (Sandbox Code Playgroud) 我想要的是:
这只能用CSS和HTML(没有任何javascript)吗?
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8"/>
<title>Test</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>
<style>
*{
margin:0px;
padding:0px;
}
header, nav, article, footer, address {
display: block;
}
header{
position:relative; height: 50px; background-color:#2b2b2b;
}
footer{
height: 50px;
width:100%;
bottom: 0px;
position: fixed;
background: red;
}
#explorer{
position:relative; bottom:55px;
}
#sections{
width: 100%; height: 100%; bottom: 55px; position:fixed; background: blue;
}
</style>
</head>
<body style="background-color:yellow">
<header >
<h1>Test</h1>
</header>
<div id="explorer" >
<div id="sections" > …Run Code Online (Sandbox Code Playgroud) 我正在寻找具有这些功能的库:
- 可以保存和加载来自wav文件,压缩到/从Mp3是一个选项但不是必需的
- 让我有可能改变音频文件的一部分的速度,音量和音调
你知道吗?我可以在C#应用程序中使用这样的开源库吗?