在我的Rails应用程序运行时收到此警告guard init rspec:
Warning: you have a Gemfile, but you're not using bundler or
RUBYGEMS_GEMDEPS
14:54:15 - INFO - Writing new Guardfile to
/home/ubuntu/railsprojects/sillyfish/Guardfile 14:54:16 - INFO - rspec
guard added to Guardfile, feel free to edit it
Run Code Online (Sandbox Code Playgroud)
我不明白为什么会这样.可以忽略这个警告吗?
这是我的Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.4'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem …Run Code Online (Sandbox Code Playgroud) 我现在正在我的应用程序中实现omniauth功能.一切正常,除了我不能从Facebook获得名字和姓氏.这是我的型号代码.
def self.from_omniauth(auth)
user = User.where(email: auth.info.email).first
if user
return user
else
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.first_name = auth.info.first_name
user.last_name = auth.info.last_name
user.email = auth.info.email
user.image = auth.info.image
user.password = Devise.friendly_token[0,20]
end
end
Run Code Online (Sandbox Code Playgroud)
我已经为设计正确设置了强大的参数,因为我现在使用它进行默认身份验证并且工作正常.是否还需要来自facebook的名字和姓氏的其他权限?
我正在使用谷歌地方api自动完成位置作为用户类型.但是,我如何将建议限制在特定国家/地区?
这是我的javascript
function initAutocomplete() {
// Create the search box and link it to the UI element.
var input = document.getElementById('autocomplete-input');
var searchBox = new google.maps.places.SearchBox(input);
// [START region_getplaces]
// Listen for the event fired when the user selects a prediction and retrieve
// more details for that place.
searchBox.addListener('places_changed', function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}
});
}
Run Code Online (Sandbox Code Playgroud) 我遇到flex滑块问题,因为如果我使用ng-repeat,它会停止工作.否则它的工作正常.
myApp.controller('frontCtrl', function ($scope) {
var results = {"id":4,"title":"sddddddd", "photos":[{"url":"http://placekitten.com/g/400/200","id":1},{"url":"http://placekitten.com/g/400/200","id":2}]};
$scope.images=results.photos
});
myApp.directive('flexslider', function () {
return {
link: function (scope, element, attrs) {
element.flexslider({
animation: "slide"
});
}
}
});
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="flexslider" flexslider>
<ul class="slides">
/* This wont work*/
<li ng-repeat="img in images">
<img src="{{img.url}}">
</li>
/* This work*/
<li>
<img src="http://placekitten.com/g/400/200">
</li>
<li>
<img src="http://placekitten.com/g/400/200">
</li>
<li>
<img src="http://placekitten.com/g/400/200">
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我已经在一个标题中重新创建了这个问题http://plnkr.co/edit/P2AOwQY0fQSMSXUQbc9t?p=preview
我正在尝试将payumoney支付网关集成到我的rails应用程序中.
我添加了gem active_merchant_payu_in,但是在此之后我无法启动app "warning: already initialized constant APP_PATH ".. 并且得到这个控制台错误..我发现这个模块来自于activemerchant我安装在我的gemfile而不是这个,现在我的应用程序启动.
根据文档,这是我们设置activemerchant的方式
ActiveMerchant::Billing::Base.mode = :test
::SAMPLEGATEWAY = ActiveMerchant::Billing::TrustCommerceGateway.new(
:login => 'TestMerchant',
:password => 'password')
Run Code Online (Sandbox Code Playgroud)
因此,对于payu我改变了网关下面,但我应该怎么传递的,而不是:login和:password在下面的代码?
ActiveMerchant::Billing::Base.mode = :test
::GATEWAY = ActiveMerchant::Billing::PayuInGateway.new(
)
Run Code Online (Sandbox Code Playgroud)
对于payumoney我们都有
商家ID,商家钥匙,商家盐
我无法在任何地方找到足够的文档.有人可以对这个话题有所了解吗?
我只是在 Rails 应用程序上试用 JWT 令牌,使用这个 jwt 库:https : //github.com/jwt/ruby-jwt
JWT.encode({sss: "333"}, 'SECRET_KEY')
Run Code Online (Sandbox Code Playgroud)
返回以下令牌:
eyJhbGciOiJIUzI1NiJ9.eyJzc3MiOiIzMzMifQ.CwX_1FztYHVpyx_G27u938SceilsVc5AB5Akwqlo2HA
然后我使用上面的令牌解码
JWT.decode("eyJhbGciOiJIUzI1NiJ9.eyJzc3MiOiIzMzMifQ.CwX_1FztYHVpyx_G27u938SceilsVc5AB5Akwqlo2HA", 'SECRET_KEY')
Run Code Online (Sandbox Code Playgroud)
正确返回以下响应:
[{"sss"=>"333"}, {"alg"=>"HS256"}]
但是,如果我尝试将令牌的最后一个字母更改为B而不是当前的A,它仍然返回相同的响应,这很奇怪。
JWT.decode("eyJhbGciOiJIUzI1NiJ9.eyJzc3MiOiIzMzMifQ.CwX_1FztYHVpyx_G27u938SceilsVc5AB5Akwqlo2HB", 'SECRET_KEY')
Run Code Online (Sandbox Code Playgroud)
即使我提供的令牌是错误的,也会收到此响应:
[{"sss"=>"333"}, {"alg"=>"HS256"}]
实际上,我对所有字符都得到了相同的响应,直到 'D'
如果我使用F上面的和其他人,那么它会按预期显示错误:
JWT.decode("eyJhbGciOiJIUzI1NiJ9.eyJzc3MiOiIzMzMifQ.CwX_1FztYHVpyx_G27u938SceilsVc5AB5Akwqlo2HF", 'SECRET_KEY')
Run Code Online (Sandbox Code Playgroud)
JWT::VerificationError(引发签名验证)来自 (irb):34
这可能是什么原因?这是预期的行为还是我在这里做错了什么?
运行时bundle exec guard收到这些警告。
<main>:1: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-0.12.2/lib/pry/commands/whereami.rb:40: warning: in `eval'
<main>:1: warning: __LINE__ in eval may not return location in binding; use Binding#source_location instead
/home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-0.12.2/lib/pry/commands/whereami.rb:41: warning: in `eval'
<main>:1: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-0.12.2/lib/pry/method/weird_method_locator.rb:88: warning: in `eval'
<main>:1: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-0.12.2/lib/pry/method/weird_method_locator.rb:80: warning: in `eval'
Run Code Online (Sandbox Code Playgroud)
它显然来自 pry gem …
我正在使用ransack进行搜索,现在我想在我的rails应用程序中实现分页.所以我使用了will_paginate gem.我面临的问题是,我无法弄清楚如何将paginate放在我当前的控制器代码中,因为它已根据查询获取结果.
这是我的控制器代码
def search
if params[:search].present? && params[:search].strip != ""
session[:loc_search] = params[:search]
end
arrResult = Array.new
if session[:loc_search] && session[:loc_search] != ""
@rooms_address = Room.where(active: true).near(session[:loc_search], 5, order: 'distance')
else
@rooms_address = Room.where(active: true).all
end
@search = @rooms_address.ransack(params[:q])
@rooms = @search.result
@arrRooms = @rooms.to_a
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何在这里加分吗?
用日志更新
18:29:40 web.1 | Room Load (0.8ms) SELECT rooms.*, 3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((12.9715987 - rooms.latitude) * PI() / 180 / 2), 2) + COS(12.9715987 * PI() / 180) * COS(rooms.latitude * PI() …Run Code Online (Sandbox Code Playgroud) 我的get路线中有一条如下路线.如何检查请求是xhr还是正常的http请求?
我想要做的是重定向,如果它http,如果xhr它将转到下面controller和action
#if xhr
get '/search' => 'pages#search'
#if http
get '/search' => redirect("/")
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做routes.rb???
根据BoraMa的回答,这里是routes.rb
Rails.application.routes.draw do
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
devise_for :users,
:path => '',
:path_names => {:edit => 'profile'},
:controllers => {:registrations => 'registrations'}
resource :pages, only: [:edit] do
collection do
patch 'update_password'
end
end
resources :conversations, only: [:create, :index] do
resources :messages, only: [:create, :index]
end
resources :notifications do
collection do
post :mark_as_read …Run Code Online (Sandbox Code Playgroud) 嗨,我有一个约150mb的统一游戏.我需要将其上传到谷歌Playstore.任何人都知道有任何解决方法吗?
guard ×2
javascript ×2
ruby ×2
android ×1
angularjs ×1
base64 ×1
devise ×1
facebook ×1
flexslider ×1
google-play ×1
jquery ×1
jwt ×1
omniauth ×1
pagination ×1
payu ×1
payumoney ×1
ransack ×1
rspec ×1
rspec-rails ×1