My home on the web.
hugochougt / old-blog Goto Github PK
View Code? Open in Web Editor NEWMy old blog
Home Page: https://hugochougt.com/old-blog
My old blog
Home Page: https://hugochougt.com/old-blog
方法签名:to_sql(arel, binds = [])
- Converts an arel AST to SQL
还要学习下 arel AST。
Ruby 的 attr_accessor
与 Rails 的 attr_accessible
是不同的。
collections.sum(&:column)
是遍历,collections.sum(:column)
是一条 SQL 查询。
本质就是要找到对应的 polymorphic type 和 id。
经过搜索有三种主要方法:
def tempfile_to_uploaded_file(tempfile)
if tempfile && tempfile.is_a?(Hash) && tempfile[:tempfile]
ActionDispatch::Http::UploadedFile.new tempfile
else
tempfile
end
end
Once run rails new
command, add gem 'sprockets', '2.12.3'
to Gemfile, then follow the tutorial on Zero to deployment in less than 10,000 words
Gems:
# https://github.com/savonrb/savon
# Heavy metal SOAP client
gem 'savon', '~> 2.10.0'
# Rails 3/4 SOAP server library
# https://github.com/inossidabile/wash_out
gem 'wash_out', '~> 0.9.2'
测试代码示例
c = Savon.client do
wsdl "http://xxx.com/llll/wsdl"
wsse_auth 'aaa', 'ddd'
end
r = c.call :update_song, message: { id: '1115', reason: '啊啊~~~五~~~环~~' }
r.body
start_date = "2015-01-01".to_date
end_date = "2015-01-02".to_date
Model.where(created_at: start_date..end_date)
这段代码有什么问题?
file_name = "#{foo}-#{bar}.txt"
file_path = Rails.root.join("tmp", file_name)
现在的 mediator 主题在显示代码块的时候太丑。
Model 里有 default_scope { order('id DESC') }
。
使用 Model#unscoped
取消 default_scope 的副作用,具体例子如 Model.unscoped.search(params[:search])
。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.