我不知道为什么我不能使用机架攻击宝石这里我做了什么
的Gemfile
gem 'rack-attack'
Run Code Online (Sandbox Code Playgroud)
我安装了宝石
配置/ application.rb中
config.middleware.use Rack::Attack
Run Code Online (Sandbox Code Playgroud)
初始化/机架attack.rb
class Rack::Attack
throttle('logins/ip', :limit => 5, :period => 60.seconds) do |req|
if req.path == '/login' && req.post?
Rails.logger.error("Rack::Attack Too many login attempts from IP: #{req.ip}")
req.ip
end
end
end
Run Code Online (Sandbox Code Playgroud)
的routes.rb
post 'login' => 'index#create'
root 'index#new'
get 'login' => 'index#new'
Run Code Online (Sandbox Code Playgroud)
我正在使用Rails 4.2.3和机架攻击宝石4.3.0
我想知道我想念的是什么
有人可以解释一下吗?,它来自红宝石指南
<%= collection_select(:person, :city_id, City.all, :id, :name) %>
Run Code Online (Sandbox Code Playgroud)
我有一个附件模型,我想在创建对象时使用combobox选择它的版本,而且我还想要一个新版本选项.
附件有什么附件
def change
create_table :attachments do |t|
t.string :filename
t.attachment :file
t.string :version
t.text :description
t.timestamps null: false
end
Run Code Online (Sandbox Code Playgroud)
更新:
<%= f.collection_select( :version, Attachment.where.not(version: nil), :version, :version) %>
Run Code Online (Sandbox Code Playgroud)
它是这样的,但我不明白,