geocoder = Baidu::Geocoder.new
geocoder.lookup(ip: '221.131.192.80')
geocoder.lookup(address: '杭州长江南路336')
geocoder.lookup(lng: 120.208955, lat: 30.16512)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'cloopen_rest', github: '9577/cloopen_rest', require: false | |
# -*- encoding: utf-8 -*- | |
require 'cloopen_rest' | |
def auth | |
{ | |
uid: 'aaf98fda45d5903f0145d5e642590064', | |
tid: 'f3cb84d5e3a74f2e82ab3bca39d3160a', | |
aid: 'aaf98fda45d5903f0145d5ecaace0077' |
新增方法
class ActiveRecord::Base
def self.has_translation(*attributes)
attributes.each do |attribute|
define_method "#{attribute}" do
self.send "#{attribute}_#{I18n.locale.to_s.downcase.sub('-','_')}"
end
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
class ActiveRecord::Base | |
class << self | |
# 去重 | |
def divorce_by(field_name, id = :id) | |
ids = twin_ids_by(field_name, id) | |
self.where(id: ids).delete_all unless ids.empty? | |
end | |
# 找出重复的 ids |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% # app/views/orders/_filter_form.html.erb %> | |
<%= t '.provider' %> | |
<%= t '.start_at' %> | |
<%= t '.end_at' %> | |
<%= t '.no' %> | |
<%= t '.mobile' %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="javascript:location.href=document.referrer;">支持 target=' _blank' </a> | |
<a href="javascript:history.back();">不支持</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'faraday', require: false | |
gem 'typhoeus', require: 'typhoeus/adapters/faraday' # Faraday adapter | |
gem 'oj', require: false # MultiJson adapter | |
gem 'multi_json' |
# 测试数据
def example
{
"[email protected]" => {
user_id: 1,
username: 'Mimosa',