当我
render json: {
error: "No such user; check the submitted email address",
status: 400
}
Run Code Online (Sandbox Code Playgroud)
然后做我的测试并检查
response.code
Run Code Online (Sandbox Code Playgroud)
我得到200而不是400
我肯定这个荒谬简单的答案,但我一直在寻找一个小时,似乎无法让这个工作.我可以解析Json,然后检查状态代码......但是有没有办法让response.code返回状态?我理解技术上它是成功的,我认为这就是为什么response.code返回200,但我之前使用的是Jbuilder,直接影响返回的代码.
我需要安装了需要qt库的capybara-webkit,所以我使用以下命令使用自制软件安装它们
brew update
brew install qt
brew linkapps
Run Code Online (Sandbox Code Playgroud)
然后我捆绑了所有与capybara-webkit很好.但是,我的警卫正在抛出以下警告.
You appear to have an outdated version of libyaml (0.1.4) installed on your system.
Prior to 0.1.6, libyaml is vulnerable to a heap overflow exploit from malicious YAML payloads.
The easiest thing to do right now is probably to update Psych to the latest version and enable
the 'bundled-libyaml' option, which will install a vendored libyaml with the vulnerability patched:
gem install psych -- --enable-bundled-libyaml
Run Code Online (Sandbox Code Playgroud)
看似简单.然而,即使在使用'bundled-libyaml'选项进行成功的心理安装之后,我仍然看到关于过时的libyaml的警告.此外,当我检查与psyche相关的libyaml版本(ruby -rpsych -e'p Psych.libyaml_version')时,它仍然是1.4.
有任何想法吗?
我的服务器抛出了这个错误
Sox::Error (sox FAIL formats: no handler for file extension `mp3'
)
Run Code Online (Sandbox Code Playgroud)
这个人(https://superuser.com/questions/421153/how-to-add-a-mp3-handler-to-sox)也有类似的问题。那里列出的解决方案是
sudo apt-get install libsox-fmt-mp3
Run Code Online (Sandbox Code Playgroud)
运行此命令后,我仍然遇到相同的错误,因此我卸载了sox(sudo apt-get remove sox),然后重新安装了它。在这一点上,我有信心他们都已安装了最新版本,因为任何尝试安装它们都会产生此问题。
libsox-fmt-mp3 is already the newest version.
sox is already the newest version.
Run Code Online (Sandbox Code Playgroud)
但是,我仍然收到相同的错误。
知道我缺少什么吗?
编辑:
我正在使用ruby-sox gem(https://github.com/TMXCredit/ruby-sox),它表示以下内容就足够了。
apt-get install libsox-fmt-all sox libchromaprint-dev
Run Code Online (Sandbox Code Playgroud)
但是所有这些都已安装,仍然没有骰子。
编辑:
我能弄清楚这种情况发生的唯一方法是,如果sox在错误的位置寻找lib文件。考虑到这些细节可能会有所帮助,
sudo find / -name sox
/usr/bin/sox
/usr/lib/x86_64-linux-gnu/sox
/usr/lib/mime/packages/sox
/usr/share/doc/sox
/home/deployer/apps/eko/shared/bundle/ruby/2.1.0/gems/ruby-sox-0.0.1/lib/sox
sudo find / -name libsox-fmt-mp3
/usr/share/doc/libsox-fmt-mp3
Run Code Online (Sandbox Code Playgroud)
当我卸载sox(apt-get remove sox)时,当我搜索sox时得到了这个
ubuntu@ip-10-0-0-9:~$ sudo find / -name sox
/usr/lib/x86_64-linux-gnu/sox
/home/deployer/apps/eko/shared/bundle/ruby/2.1.0/gems/ruby-sox-0.0.1/lib/sox
Run Code Online (Sandbox Code Playgroud)
为了摆脱这种袜子,希望回到除了宝石体验之外的任何地方都没有袜子,我尝试了
sudo apt-get …Run Code Online (Sandbox Code Playgroud) 我正在使用Rails + Devise进行登录和注册,但我的前端绝大多数都使用角度路由.当有人试图在没有登录的情况下转到特定页面时,我希望在成功登录后重定向它们.通常,这将是在会话中存储路径和修改after_sign_in_path_for方法的简单问题.但是,我似乎无法找到有效获取实际路径的Rails方法.我有信心我可以通过JS做到这一点,然后将其存储为cookie(或者真的是Angular),但我更喜欢将它保存在Rails中.有没有一种我想念的方法会给我一些实际的路径,包括/#/ what/whatever?
似乎以下应该有效:
request.original_url
Run Code Online (Sandbox Code Playgroud)
基于此(http://api.rubyonrails.org/classes/ActionDispatch/Request.html)
但它没有返回主题标签或以下参数.
也许是由于这个人说的话(没有哈希'#'的AngularJS路由)
#是一个旧的浏览器短路,它不会触发请求,这允许许多js框架在其上构建自己的客户端重新路由.
有没有一种干净的方法来收集Rails中的完整路径,还是我需要进入Angular/JS?
上传文档的API示例是这样的
headers = {
'Authorization': 'Bearer ACCESS_TOKEN',
}
params = {
'doctor': 'https://drchrono.com/api/doctors/1234',
'patient': 'https://drchrono.com/api/patients/5678',
'description': 'Short document description here',
'date': '2014-02-24',
'metatags': json.dumps(['tag1', 'tag2']),
}
with open('/path/to/your.pdf', 'rb') as f:
files = {'document': f}
requests.post(
'https://drchrono.com/api/documents',
data=params, files=files, headers=headers,
)
Run Code Online (Sandbox Code Playgroud)
我使用Prawn来创建PDF.一个路由自动下载PDF,而另一个路由使其在浏览器中查看.我遇到了问题(试图弄清楚它是Prawn PDF问题还是PDF问题)我从网上下载了一个相当基本的PDF.同样的问题.我正在使用HTTParty发送我的POST请求.
headers = {'Authorization' => 'Bearer ' + access_token}
File.open("#{Rails.root}/app/assets/test.pdf", "rb") do |file|
params = {
'document' => file.read,
'doctor' => 'https://drchrono.com/api/doctors/' + doctor.id,
'patient' => 'https://drchrono.com/api/patients/' + patient.id,
'description' => 'Report',
'date' => date
}
response = …Run Code Online (Sandbox Code Playgroud) 我有一个包含表格的可滚动div,我希望最后三个可见行变得越来越不清晰,慢慢淡入背景颜色.效果将非常像这样(http://css-tricks.com/examples/FadeOutBottom/),但有一个表格.最初,我选择div的最后三个可见行,并对元素应用降低不透明度.这有效,但要求我不断重新评估滚动发生时最后三行是哪一行; 混乱.
我的下一个想法是在表格上应用一个div来模仿页面的背景,并且(最初)100%透明但随后在应用模仿的背景时慢慢降低透明度,有效地隐藏行越来越多.但是我的背景不是一个恒定的颜色,它是从颜色A到颜色B的渐变,我有很大的问题模仿背景而没有以完全相同的方式创建它(高度100%的页面,渐变从颜色A到颜色B).如果我能做到这一点,但随后也说,嘿div与我的背景的确切颜色,我希望你最初100%透明,所以实际的背景是在div的顶部,但你的身体的底部x百分比我希望透明度降低,因此你的颜色应用在基础表上,从而使文本变暗......好吧,那就是完美的.
我最初认为从透明到渐变B将完成我正在寻找的但没有骰子; 回想起来,从颜色A到颜色B的颜色步骤与从透明颜色到颜色B时发生的颜色步骤不同并不令人惊讶.
现在正在开发一个快速的jFiddle,但我想我会把它放在那里,以防有一个我忽略的简单的CSS组件或技术.
我正在尝试将我的全栈导轨应用程序一次移动到Angular页面.我正在使用ui-router(https://github.com/angular-ui/ui-router)和angular-rails-templates(https://github.com/pitr/angular-rails-templates).我假设nghaml扩展允许我继续在我的haml中使用rails helper,例如link_to,paths等,所以只需将我的haml页面复制并粘贴到模板中; 在理想的世界中,我现在处于一个页面,即客户端提供一个页面,而其他每个页面(包括它链接到的页面)仍然在服务器端提供服务.相反,我得到的错误如下:
undefined local variable or method `dashboard_patients_path' for #<Object:0x007fc87865cff0>
Run Code Online (Sandbox Code Playgroud)
和link_to等
我认为这个(带有客户端haml的angularjs)将是一个可靠的解决方案,特别是sharpper的响应,因为它似乎直接适用.
module CustomHamlEngine
class HamlTemplate < Tilt::HamlTemplate
def evaluate(scope, locals, &block)
scope.class_eval do
include Rails.application.routes.url_helpers
include Rails.application.routes.mounted_helpers
include ActionView::Helpers
end
super
end
end
end
Rails.application.assets.register_engine '.haml', CustomHamlEngine::HamlTemplate
Run Code Online (Sandbox Code Playgroud)
但是,即使重新启动服务器,也没有骰子.
思考?