Module: Ramaze::Helper::Section

Defined in:
lib/zen/package/sections/lib/sections/helper/section.rb

Overview

Helper for the sections package.

Since:

Instance Method Summary (collapse)

Instance Method Details

- (Sections::Model::Section) validate_section(section_id)

Validates the section ID and returns the section if it's valid.

Parameters:

  • section_id (Fixnum)

    The ID of the section to validate.

Returns:

Since:

  • 0.2.8



16
17
18
19
20
21
22
23
24
25
# File 'lib/zen/package/sections/lib/sections/helper/section.rb', line 16

def validate_section(section_id)
  section = Sections::Model::Section[section_id]

  if section.nil?
    message(:error, lang('sections.errors.invalid_section'))
    redirect(Sections::Controller::Sections.r(:index))
  else
    return section
  end
end

- (Sections::Model::SectionEntry) validate_section_entry(section_entry_id, section_id)

Validates a section entry and returns it if it's valid.

Parameters:

  • section_entry_id (Fixnum)

    The ID of the section entry to validate.

  • section_id (Fixnum)

    The ID of the section to use when redirecting the user to the overview of all entries.

Returns:

Since:

  • 0.2.8



38
39
40
41
42
43
44
45
46
47
# File 'lib/zen/package/sections/lib/sections/helper/section.rb', line 38

def validate_section_entry(section_entry_id, section_id)
  entry = Sections::Model::SectionEntry[section_entry_id]

  if entry.nil?
    message(:error, lang('section_entries.errors.invalid_entry'))
    redirect(Sections::Controller::SectionEntries.r(:index, section_id))
  else
    return entry
  end
end