我想在我的Users activeadmin页面上实现一个自定义操作(notify_all),单击该页面时将显示一个表单,该表单在提交时将路由到另一个自定义操作(send_notification_to_all).到目前为止,我一直无法使第二部分工作.
管理员/ users.rb的:
ActiveAdmin.register User do
action_item :only => :index do
link_to 'Notify All', notify_all_admin_users_path
end
collection_action :notify_all, :method => :get do
puts "notifying...."
end
collection_action :send_notification_to_all, :method => :post do
puts "sending notification...."
end
end
Run Code Online (Sandbox Code Playgroud)
单击"通知全部"按钮时,将呈现以下视图.意见/管理/用户/ notify_all.html.erb
<form action="send_notification_to_all" method="post">
<div><textarea rows="10" cols="100" placeholder="Enter message here"></textarea></div>
<div><input type="submit"></div>
</form>
Run Code Online (Sandbox Code Playgroud)
提交此表单后,我收到401 Unauthorized错误:
Started POST "/admin/users/send_notification_to_all" for 127.0.0.1 at 2014-02-12 14:08:27 -0600
Processing by Admin::UsersController#send_notification_to_all as HTML
WARNING: Can't verify CSRF token authenticity
AdminUser Load (0.8ms) SELECT "admin_users".* FROM "admin_users" …Run Code Online (Sandbox Code Playgroud) 我正在使用ruby on rails教程进行练习,该教程涉及安装postgresql.按照教程中链接的rails cast的说明,我做到了
brew install postgresql
Run Code Online (Sandbox Code Playgroud)
brew unlink ossp-uuid && brew link ossp_uuid
Run Code Online (Sandbox Code Playgroud)
我不知道这是在做什么.命令失败(我认为第一部分成功).错误:
无法符号链接文件:/usr/local/Cellar/ossp-uuid/1.6.2/share/man/man3/uuid.3/usr/local/share/man/man3不可写.您应该更改其权限.
这是关于什么的?为什么我们需要创建这个符号链接?
提前致谢!
我从dribbble下载了一个调色板.具体来说,一个来自
http://dribbble.com/shots/665606-The-Design-Blog?list=users
(单击调色板旁边的泪滴图标)
该文件是一个.aco文件,当我在Photoshop(Adobe Photoshop CS6,版本13.0.1 x64)中打开时,Photoshop会抱怨意外的文件结束:
是否有可能弄清楚文件有什么问题,或者我在Photoshop中需要做些什么才能打开这些类型的文件?
谢谢.
我试图在IntelliJ中运行一个小测试程序.码:
String driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url = "jdbc:sqlserver://test.test.com;integratedSecurity=true";
String userName = "test";
String password = "test";
Class.forName(driverClass);
try (Connection con = DriverManager.getConnection(url, userName, password);
Statement st1 = con.createStatement();
Statement st2 = con.createStatement();
) {
String sql1 = "EXEC [dbo].[Cleanup]";
String sql2 = "EXEC [dbo].[DetailsALL] \"DetailsALL.csv\" ";
st1.execute(sql1);
st2.execute(sql2);
}catch(Exception e){
System.out.println(e.getMessage());
}
Run Code Online (Sandbox Code Playgroud)
我在VM选项中添加了以下内容:
-Djava.library.path = "\ Users \用户sgupta\IdeaProjects \待办事项\ sqljdbc_4.0\ENU\AUTH\86 \"

运行该程序会导致:
2013年4月5日下午5:43:20 com.microsoft.sqlserver.jdbc.AuthenticationJNI警告:无法加载sqljdbc_auth.dll原因:java.library.path中没有sqljdbc_auth此驱动程序未配置为集成身份验证.ClientConnectionId:db8a3aa3-d84b-49d2-a7eb-64c4187a8303
我已经仔细检查了我在VM选项中指定的路径.还有其他建议吗?谢谢.
我知道有很多关于将NSData转换为NSString,将NSData转换为Base64编码的字符串,生成HMAC等的文章,但是似乎都没有答案如何在iOS和Rails中生成匹配的Base64编码的HMAC-SHA1字符串。
使用下面的代码,签名不匹配。
iOS程式码:
NSString *secret = @"xxx";
NSString *data = @"http://someurl?someparams";
const char *cKey = [secret cStringUsingEncoding:NSASCIIStringEncoding];
const char *cData = [data cStringUsingEncoding:NSASCIIStringEncoding];
unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC length:sizeof(cHMAC)];
NSString *signature = [HMAC base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
Run Code Online (Sandbox Code Playgroud)
Rails代码:
secret = "xxx";
data = "http://someurl?someparams";
hmac = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha1'), secret.encode("ASCII"), data.encode("ASCII"))
signature = Base64.encode64(hmac)
puts "HMAC #{hmac}"
puts "Signature #{signature}"
Run Code Online (Sandbox Code Playgroud)
iOS输出:
HMAC <05651433 c9a3d449 5816ded7 80bef87f dc903e4a>
Signature BWUUM8mj1ElYFt7XgL74f9yQPko=
Run Code Online (Sandbox Code Playgroud)
Rails输出:
HMAC 05651433c9a3d4495816ded780bef87fdc903e4a
Signature MDU2NTE0MzNjOWEzZDQ0OTU4MTZkZWQ3ODBiZWY4N2ZkYzkwM2U0YQ==
Run Code Online (Sandbox Code Playgroud)
使用以下代码,我可以使它们匹配。但是感觉很hacky(在iOS端和 …
我在Parse的论坛上问过这个问题,但是在14个小时内没有收到回复,所以无论如何我都回到了我的第一选择,好吧.
我正在测试使用查询发送推送通知.我很确定我在查询中使用了正确的安装ID.但推送没有被发送到我的设备.也许语法有问题?
curl -X POST \
-H "X-Parse-Application-Id: xxx" \
-H "X-Parse-REST-API-Key: yyy" \
-H "Content-Type: application/json" \
-d '{"where":{"id":{"in":["8e40a0b9-edef-442b-ad1a-3b5eb8c7fd8b"]}},"data":{"alert":"d"}}'\
https://api.parse.com/1/push
Run Code Online (Sandbox Code Playgroud)
给出了回复:
{"result":true}
Run Code Online (Sandbox Code Playgroud)
但是没有发送通知.在Parse的仪表板上,我看到以下内容:


这里有Parse API经验的人知道我的查询或请求可能有什么问题吗?此外,如果有人对此有意见,请告诉我:如果有100个需要通知的安装ID,您是否看到使用上述查询的任何潜在问题?
显而易见,我不是CSS专家.我上课了
.hidden{
display:hidden
}
Run Code Online (Sandbox Code Playgroud)
和一个div
<div class="hidden">
</div>
Run Code Online (Sandbox Code Playgroud)
但是在呈现页面时不会隐藏div.当我查看Chrome中的Computed样式时,它表示显示属性已被用户代理样式表覆盖.为什么?
我正在编写一个rake任务来从备份文件中恢复数据库,该文件是存储在S3中的.tar.gz.
第1步,从S3下载文件,对吗?我正在使用right_aws的S3Interface.我尝试了简单的get,它返回文件内容:object.
obj = s3.get(s3_config[:s3_bucket], s3_file_name)
temp_file.write obj[:object]
Run Code Online (Sandbox Code Playgroud)
错误:耙子中止了!"\ x8B"从ASCII-8BIT到UTF-8
我看到一些关于使用GzipWriter和String#unpack的帖子,但无法成功应用它们.
我Api::V1::UsersController在app/controllers/api/v1中有一个控制器.我Api::V1::ErrorHelper在app/helpers/api/v1中有一个帮助模块.
我想访问控制器内的辅助模块的方法.所以,我调用了控制器的辅助方法,将模块传递给它:
class Api::V1::UsersController < ApplicationController
helper Api::V1::ErrorHelper
#other code
end
Run Code Online (Sandbox Code Playgroud)
但是当我访问控制器内部的一个辅助方法(respond_with_error)时,我得到以下异常:
undefined method `respond_with_error' for #<Api::V1::UsersController:0x007fad1b189578>
Run Code Online (Sandbox Code Playgroud)
如何从控制器访问此帮助程序?
(我使用的是Rails 3.2)
谢谢.
我有一个名为Product的核心数据实体,最初在用户首次登录应用程序时填充.如果用户请求刷新,则可以再次加载它.
在应用程序的多个位置查询Product实体.所以,我决定实现一个可以在应用程序中共享的简单缓存.缓存将Product NSManagedObjects保存在地图中.这是一个坏主意吗?
@interface ProductCache ()
@end
@implementation ProductCache {
}
static NSDictionary *productsDictionary = nil;
static ProductCache *sharedInstance;
+ (ProductCache *)sharedInstance {
@synchronized (self) {
if (sharedInstance == nil) {
sharedInstance = [[self alloc] init];
[sharedInstance reload];
}
}
return sharedInstance;
}
- (void) reload{
NSMutableDictionary *productsMap = [[NSMutableDictionary alloc] init];
CIAppDelegate *delegate = (CIAppDelegate *) [UIApplication sharedApplication].delegate;
NSManagedObjectContext *managedObjectContext = delegate.managedObjectContext;
NSArray *allProducts = [CoreDataManager getProducts:managedObjectContext];
for (Product *product in allProducts) {
[productsMap setObject:product forKey:product.productId];
}
productsDictionary …Run Code Online (Sandbox Code Playgroud)