【文件属性】:
文件名称:decent_exposure:在控制器中创建声明性接口的助手
文件大小:67KB
文件格式:ZIP
更新时间:2021-02-23 07:43:47
Ruby
安装
将此行添加到您的应用程序的Gemfile中:
gem 'decent_exposure' , '~> 3.0'
然后执行:
$ bundle
或将其自己安装为:
$ gem install decent_exposure
API
到目前为止,整个API包含三种方法: expose , expose! 和exposure_config 。
在最简单的情况下,您将使用它在控制器中公开模型:
class ThingsController < ApplicationController
expose :thing
end
现在,每次通话时间thing在你的控制器或视图,它会寻找一个ID,并尝试执行Thing.find(id) 如果找不到该ID,它将调用Thing.new(thing_params) 。 结果将存储在@exposed_thing实例变量中。
控制器实例
这是
【文件预览】:
decent_exposure-master
----.travis.yml(405B)
----decent_exposure.gemspec(1KB)
----Rakefile(107B)
----.github()
--------workflows()
----gemfiles()
--------Gemfile.rails-5.0.0(72B)
--------Gemfile.rails-6.0.0(72B)
----Gemfile(51B)
----doc()
--------decent_exposure.png(46KB)
----spec()
--------features()
--------support()
--------decent_exposure()
--------generators()
--------spec_helper.rb(26B)
----.gitignore(180B)
----CHANGELOG.md(488B)
----lib()
--------decent_exposure()
--------decent_exposure.rb(658B)
--------generators()
----README.md(9KB)
----LICENSE.txt(1KB)