Module: ActionCrud::Helpers::View

Defined in:
lib/action_crud/helpers/view.rb

Instance Method Summary collapse

Instance Method Details

#current_modelObject

Get current model



5
6
7
# File 'lib/action_crud/helpers/view.rb', line 5

def current_model
  controller.try(:current_model)
end

#current_recordObject

Get current record



10
11
12
# File 'lib/action_crud/helpers/view.rb', line 10

def current_record
  controller.try(:current_record) || current_model.try(:new)
end

#current_recordsObject

Get current records



15
16
17
# File 'lib/action_crud/helpers/view.rb', line 15

def current_records
  controller.try(:current_records) || []
end

#permitted_paramsObject

Get permitted parameters



20
21
22
# File 'lib/action_crud/helpers/view.rb', line 20

def permitted_params
  controller.try(:permitted_params) || []
end

Get record link



25
26
27
28
29
30
# File 'lib/action_crud/helpers/view.rb', line 25

def record_link_to(record=nil, *args)
  options = args.extract_options!
  action  = args.first

  ActionCrud::Helpers::Link.new(self, record, action, options).render
end

Get record links



33
34
35
36
37
38
39
40
41
# File 'lib/action_crud/helpers/view.rb', line 33

def record_links_to(record=nil, *args)
  options = args.extract_options!
  default = options.fetch :html, {}
  options = options.except(:html)
  actions = args.concat(options.keys)
  actions = actions.any? ? actions : [:show, :edit, :destroy]

  ActionCrud::Helpers::Link.new(self, record, actions, default).render_multiple(options)
end