我正在使用本地服务器来测试应用程序,并从我自己的机器向该服务器发出请求.
测试服务器的SSL很糟糕,因此HTTParty会抛出错误.根据我的阅读,HTTParty默认情况下应该忽略SSL,但是当我尝试这样做时:
HTTParty.get( "#{ @settings.api_server }#{ url }" ).parsed_response
Run Code Online (Sandbox Code Playgroud)
它抛出此错误:
OpenSSL::SSL::SSLError at /
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
Run Code Online (Sandbox Code Playgroud)
如何让它忽略SSL?
我正在构建一个简单的应用程序,并希望能够在数据库中存储json字符串.我有一个带有json列的表接口,我希望我的rails模型验证字符串的值.所以类似于:
class Interface < ActiveRecord::Base
attr_accessible :name, :json
validates :name, :presence => true,
:length => { :minimum => 3,
:maximum => 40 },
:uniqueness => true
validates :json, :presence => true,
:type => json #SOMETHING LIKE THIS
:contains => json #OR THIS
end
Run Code Online (Sandbox Code Playgroud)
我怎么做?
我希望只有属性is_admin设置为true的用户才能访问我的活动管理员后端
我该怎么做?
"普通"用户应该只能登录该站点,而不能登录到活动管理员.
我正在尝试在我的laravel控制器上运行此功能测试.我想测试图像处理,但这样做我想伪造图像上传.我该怎么做呢?我在网上找到了一些例子,但似乎没有一个适合我.这就是我所拥有的:
public function testResizeMethod()
{
$this->prepareCleanDB();
$this->_createAccessableCompany();
$local_file = __DIR__ . '/test-files/large-avatar.jpg';
$uploadedFile = new Symfony\Component\HttpFoundation\File\UploadedFile(
$local_file,
'large-avatar.jpg',
'image/jpeg',
null,
null,
true
);
$values = array(
'company_id' => $this->company->id
);
$response = $this->action(
'POST',
'FileStorageController@store',
$values,
['file' => $uploadedFile]
);
$readable_response = $this->getReadableResponseObject($response);
}
Run Code Online (Sandbox Code Playgroud)
但是控制器没有通过这个检查:
elseif (!Input::hasFile('file'))
{
return Response::error('No file uploaded');
}
Run Code Online (Sandbox Code Playgroud)
所以文件不能正确传递.我该怎么做?
更新
基于max.lanin的建议,我也尝试过:
public function testResizeMethod()
{
$this->prepareCleanDB();
$this->_createAccessableCompany();
$local_file = __DIR__ . '/test-files/large-avatar.jpg';
$uploadedFile = new Symfony\Component\HttpFoundation\File\UploadedFile(
$local_file,
'large-avatar.jpg',
'image/jpeg',
null,
null,
true
);
$values = …Run Code Online (Sandbox Code Playgroud) 我有这个部分,它呈现一个包含跨度中包含三个和平数据的行,并且在跨度之间有一个连字符.因为连字符是haml关键字(或者你称之为的任何关键字),所以你不能将它放在跨度之间,否则haml会寻找函数或变量.所以我有这个
%p
%span{ :class => 'client'}= "#{ won_or_lost['object']['deal']['client'] }"
= "-"
%span{ :class => 'value'}= "#{ won_or_lost['object']['deal']['value'] }"
= "- Thanks to"
%span{ :class => 'owner'}= "#{ won_or_lost['object']['deal']['owner'] }
Run Code Online (Sandbox Code Playgroud)
你可能同意我的观点
=" - "
相当难看.这不是一个真正的问题,但有一个干净的方法来做到这一点?
我在Atom中使用Ruby linter,对于某些行,它会发出以下警告:
(...) interpreted as grouped expression
Run Code Online (Sandbox Code Playgroud)
获得此警告的行的示例如下:
elsif not (params[:vacancy].nil? or params[:vacancy]['company_id'].nil? or params[:vacancy]['company_id'] == "0" )
Run Code Online (Sandbox Code Playgroud)
如何改进这条线以使警告消失?
使用Spin运行Guard可以很好地保持我的测试速度,除非资产是相关的并且需要编译.似乎每当我更改其中的某些内容时,测试环境都会重新编译所有资产.我已经看到了部署脚本的示例,这些脚本只重新编译源已更改的资产.这可以用于测试吗?或者是否有另一种加速测试资产编译的方法?
我正在使用一个相当具体的设置,所以我很乐意在需要时提供更多信息,但我觉得这个问题的答案可能会在更多的情况下使用,而不仅仅是我的.
在实施AdMob时,您可以定义一系列测试ID,以便Google知道向这些设备投放测试广告,而不是真实广告.但是,它需要"散列设备ID".这对我来说似乎有点模糊.他们在谈论什么ID以及他们希望我使用什么样的哈希方法?
我在谈论应该进入的位:
request.testDevices = @[ @"hashed-device-id" ];
Run Code Online (Sandbox Code Playgroud) 在Active Admin中,是否可以为索引页面中的每个项目添加一个复选框(这并不难),并添加某种菜单以对所有选定项目执行批量操作,例如一次删除所有选定项目.
我找不到另一种方法来创建自定义页面,但我宁愿不这样做; 对我来说似乎有点矫枉过正.
我正在使用以下css来显示步数计数器:
:before {
content: "step " counter(fieldsets);
counter-increment: fieldsets;
/* Some more css */
}
Run Code Online (Sandbox Code Playgroud)
但我想知道是否有可能显示元素的总数,如下所示:
:before {
content: "step " counter(fieldsets) " of " total_number_of_fieldsets;
counter-increment: fieldsets
/* Some more css */
}
Run Code Online (Sandbox Code Playgroud)
我希望它是一个纯粹的CSS解决方案,这可能吗?