Module: RoleAuthorization::ViewSecurity::InstanceMethods
- Defined in:
- lib/role_authorization/view_security.rb
Instance Method Summary collapse
- #button_to_secured(name, options = {}, html_options = nil) ⇒ Object
- #form_for_secured(record, options = {}, &proc) ⇒ Object
- #link_to_or_show(name, options = {}, html_options = nil) ⇒ Object
- #link_to_secured(name, options = {}, html_options = nil) ⇒ Object
Instance Method Details
#button_to_secured(name, options = {}, html_options = nil) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/role_authorization/view_security.rb', line 60 def (name, = {}, = nil) url = url_for() method = ( && .has_key?(:method)) ? [:method] : :post if (url, method) return (name, url, ) else return "" end end |
#form_for_secured(record, options = {}, &proc) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/role_authorization/view_security.rb', line 18 def form_for_secured(record, = {}, &proc) url = url_for([:url] || record) # pretty much taken from form_for to figure out # the correct method to use object = case record when String, Symbol nil when Array record.last else record end object = convert_to_model(object) method = if [:html] && [:html].has_key?(:method) [:html][:method] elsif object && object.respond_to?(:persisted?) && object.persisted? :put else :post end if (url, method) return form_for_open(record, , &proc) else return "" end end |
#link_to_or_show(name, options = {}, html_options = nil) ⇒ Object
72 73 74 75 |
# File 'lib/role_authorization/view_security.rb', line 72 def link_to_or_show(name, = {}, = nil) lnk = link_to(name, , ) lnk.length == 0 ? name : lnk end |
#link_to_secured(name, options = {}, html_options = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/role_authorization/view_security.rb', line 48 def link_to_secured(name, = {}, = nil) url = url_for() method = ( && .has_key?(:method)) ? [:method] : :get if (url, method) return link_to_open(name, url, ) else return "" end end |