有没有办法告诉Rails不要div.field_with_errors在标签和实际字段div.error周围创建,而是围绕它们创建?
例如,我在表格中的片段(用HAML编写)
= form_for @user do |f|
%div.clearfix
= f.label :name
%div.input
= f.text_field :name
Run Code Online (Sandbox Code Playgroud)
我希望在错误的情况下根目录div div.clearfix.error并避免这种情况field_with_errors.我可以这样做吗?
作为另一种选择,我可以制作formtastic 来创建Bootstrap -styled元素,没有formtastic的css和html类,但是使用bootstrap的.在使用formtastic的情况下,我可以使用错误字段制作一些东西吗?
customization ruby-on-rails formtastic ruby-on-rails-3 twitter-bootstrap
我在 iOS 9 上使用 XCode 7,我正在尝试播放声音。我一直在谷歌上搜索解决方案好几天了,我已经尝试了所有可能的解决方案,但没有任何效果。
这是我的代码
。H
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@interface ViewController : UIViewController <DTDeviceDelegate, AVAudioPlayerDelegate>
{
}
Run Code Online (Sandbox Code Playgroud)
这是我的 .m 文件:
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"autumn_leaves" ofType:@"m4a"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSError *error;
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL
error:&error];
player.numberOfLoops = -1; //Infinite
[player play];
Run Code Online (Sandbox Code Playgroud)
没有声音,没有错误,没有警告,什么都没有
soundFilePath并且soundFileURL不是nil,与玩家一样,他们越来越多。我的电话音量尽可能大。
我也在 .m 文件中尝试过:
@property(strong, nonatomic) AVAudioPlayer *player;
self.myPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:fileURL error:&error];
[self.myPlayer play];
Run Code Online (Sandbox Code Playgroud)
也没有播放声音,也没有错误。
这是我的资源文件夹的屏幕截图:
请帮忙!
我有一组函数可以在元组和列表之间进行转换:
pack2 :: [a] -> (a, a)
pack2 (a:b:_) = (a, b)
unpack2 :: (a, a) -> [a]
unpack2 (a, b) = [a, b]
pack3 :: [a] -> (a, a, a)
pack3 (a:b:c:_) = (a, b, c)
unpack3 :: (a, a, a) -> [a]
unpack3 (a, b, c) = [a, b, c]
-- and so on
Run Code Online (Sandbox Code Playgroud)
我想稍微概括一下,以便以下可能:
packN [1, 2, 3, 4] :: (Int, Int) -- => (1, 2)
unpackN (1, 2, 3) -- => [1, 2, 3]
Run Code Online (Sandbox Code Playgroud)
我试图像这样解决它:
class …Run Code Online (Sandbox Code Playgroud)