运行捆绑安装后,我收到此错误:
Gem::Package::FormatError: no metadata found in /Users/jeanosorio/.rvm/gems/ruby-1.9.3-p286/cache/libv8-3.11.8.13-x86_64-darwin-12.gem
An error occurred while installing libv8 (3.11.8.13), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.11.8.13'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)
我试着用
gem install libv8 -v '3.11.8.13'
Run Code Online (Sandbox Code Playgroud)
但我明白了
ERROR: Error installing libv8:
invalid gem format for /Users/jeanosorio/.rvm/gems/ruby-1.9.3-p286/cache/libv8-3.11.8.13-x86_64-darwin-12.gem
Run Code Online (Sandbox Code Playgroud)
这里有什么问题.请帮忙.
使用以下命令在我的控制台上启动redis服务器后:
redis-server
Run Code Online (Sandbox Code Playgroud)
我像这样执行以下ruby脚本:
script/user/generate_roster_kids.rb start
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我得到:
generate_roster_kids] Pid not found, process seems doesn't exist!
[generate_roster_kids] Process daemonized with pid 1110 with thread and Forever v.0.3.2
Run Code Online (Sandbox Code Playgroud)
如果我再次执行相同的命令,我得到以下内容:
generate_roster_kids] Found pid 1110...
[generate_roster_kids] Waiting the daemon's death . DONE
[generate_roster_kids] Process daemonized with pid 1385 with thread and Forever v.0.3.2
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我做错了什么.
这是generate_roster_kids.rb文件的内容:
#!/usr/bin/ruby
require 'rubygems' unless defined?(Gem)
require 'forever'
require 'redis'
Forever.run do
REDIS = Redis.new()
#
# dir "foo" # Default: File.expand_path('../../', __FILE__)
# file "bar" # Default: __FILE__
log "bar.log" …Run Code Online (Sandbox Code Playgroud) 我有以下示例测试:
import { assert } from 'chai'
function starWarsMovies () {
fetch('http://swapi.co/api/films/')
.then((res) => {
return res.json()
})
.then((res) => res.count)
}
describe('Get star war movies', () => {
it('should get 7', () =>{
assert.equal(starWarsMovies(), 7)
})
})
Run Code Online (Sandbox Code Playgroud)
但我得到
ReferenceError: fetch is not defined
Run Code Online (Sandbox Code Playgroud)
我必须使用什么才能测试提取请求。
更新
我也尝试过:
import { polyfill } from 'es6-promise'
import fetch from 'isomorphic-fetch'
Run Code Online (Sandbox Code Playgroud)
但后来我得到:
AssertionError: expected undefined to equal 7
Run Code Online (Sandbox Code Playgroud)
我不明白为什么。
我有以下 Jest 测试代码来测试对端点的提取:
import MovieApiService from 'services/MovieApiService';
import movies from '../constants/movies';
describe('MovieApiService', () => {
test('if jest work correctly', () => {
expect(true).toBe(true);
});
test('get an array of popular movies', () => {
global.fetch = jest.mock('../mocks/movies');
const movieApiService = new MovieApiService();
return movieApiService.getPopularMovies()
.then(data => expect(data).toBe(movies));
});
});
Run Code Online (Sandbox Code Playgroud)
但我得到:
我知道这movieApiService.getPopularMovies()是一个JavaScript fetch request,但是Node.js没有 fetch API,所以我如何才能使用 Jest 使这个测试工作?
如何用值填充文本输入?我在尝试这个:
<input id="curso" maxlength="150" name="curso" size="40" type="text"
value="window.location.href.substring(91))" />
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
我正在尝试将过期时间设置为这样的 jwt 令牌:
class JsonWebToken
def self.encode(payload)
payload[:exp] = (2).minutes.from_now.to_i #expire in 2 minutes
JWT.encode(payload, Rails.application.secrets.secret_key_base)
end
def self.decode(token)
return HashWithIndifferentAccess.new(JWT.decode(token, Rails.application.secrets.secret_key_base)[0])
rescue
nil
end
end
Run Code Online (Sandbox Code Playgroud)
但是当我尝试访问 url 时,令牌始终有效。此外,如果我解码令牌,我永远不会在哈希上获得 exp key:value。
任何建议
我正在使用jwt gem
这就是我对用户进行身份验证的方式。
def authenticate_user
user = User.find_for_database_authentication(email: params[:email])
if user.valid_password?(params[:password])
render json: payload(user)
else
render json: {errors: ['Invalid Username/Password']}, status: :unauthorized
end
end
private
def payload(user)
return nil unless user and user.id
{
auth_token: JsonWebToken.encode({user_id: user.id}),
user: {id: user.id, email: user.email}
}
end
Run Code Online (Sandbox Code Playgroud)
使用 curl …
我有一个应用程序,有两个路由器主页和结果。在主页中,我必须转到我们的授权微服务并返回到我的反应应用程序,返回结果页面,但是 result.html 文件不存在,因为是反应应用程序,所以我收到 404 错误。
我正在我的 nginx 上尝试以下配置:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to …Run Code Online (Sandbox Code Playgroud) 您好我尝试为我的rails应用创建重置密码; 但是当我尝试保存时,我收到以下错误:
验证失败:密码不能为空,密码太短(最少6个字符),密码确认不能为空
这是我的用户模型.
class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation
has_secure_password
before_save { |user| user.email = email.downcase }
before_save :create_remember_token
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }
validates :password, presence: true, length: { minimum: 6 }
validates :password_confirmation, presence: true
def send_password_reset
self.password_reset_token = SecureRandom.urlsafe_base64
self.password_reset_at = Time.zone.now
self.password = self.password
self.password_confirmation = self.password
save!
end
private
def create_remember_token
self.remember_token = SecureRandom.urlsafe_base64
end
end
Run Code Online (Sandbox Code Playgroud)
方法"send_password_reset"不会更新用户,我不明白为什么尝试保存用户而不是只更新password_reset_token和password_reset_at.
请问有人可以帮助我吗?
收到一个Future[httpResponse]我试图发送消息后,sender但我失去了参考sender.
这是我的接收方法的代码:
def receive = {
case Seq(method: HttpMethod, endpoint: String, payload: String) ? {
// I have the correct sender reference
implicit val materializer: ActorMaterializer = ActorMaterializer(ActorMaterializerSettings(context.system)) // needed by singleRequest method below
// I have the correct sender reference
val response: Future[HttpResponse] = Http(context.system).singleRequest(HttpRequest(method = method, uri = endpoint, entity = payload))
println("http request sent")
// I have the correct sender reference
response onSuccess {
case HttpResponse(statusCode, _, entity, _) ? { …Run Code Online (Sandbox Code Playgroud) 我正在尝试查找和记录,记录是否为零,我不希望它在我的阵列上像这样:
@kid << Kid.find_only_kid(k) unless nil
Run Code Online (Sandbox Code Playgroud)
但是当我得到一个nil时,记录会插入到数组中.
这是我的模型上的find_only_kid方法的代码:
def self.find_only_kid(kid)
Kid.where(_id: kid.to_s, parent: false, teacher: false).first rescue nil
end
Run Code Online (Sandbox Code Playgroud)