Sha256: 175c9fd9b77766fcbe2e97d43940d703f4dd7805fb6a607eb8554991e3f647b2

Contents?: true

Size: 974 Bytes

Versions: 25

Compression:

Stored size: 974 Bytes

Contents

module Roroacms   
  class MenuOption < ActiveRecord::Base

    ## associations ##

    belongs_to :menu

    ## methods ##

    # saves the menu on the fly via an ajax call. This is a seperate function because
    # the ajax call sends through a json object. It decodes this, updates the values and saves the menu
    # Params:
    # +p+:: json object sent through from the menu page

    def self.save_menu_on_fly(p)

      return true if p[:data].blank?

      f = ActiveSupport::JSON.decode p[:data]
      MenuOption.destroy_all(:menu_id => p[:menuid])

      f.each do | record |

        opt = MenuOption.new
        opt.menu_id = p[:menuid]
        opt.parent_id = record['parent_id']
        opt.data_type = record['data_type'].to_s.gsub(/\s+/, "")
        opt.option_id = record['item_id']
        opt.lft = record['left']
        opt.rgt = record['right']

        opt.custom_data = record['custom_data']

        opt.save

      end

      true
    end

  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
roroacms-1.0.0 app/models/roroacms/menu_option.rb
roroacms-0.0.8.6.7 app/models/roroacms/menu_option.rb
roroacms-0.0.8.6.6 app/models/roroacms/menu_option.rb
roroacms-0.0.8.6.5 app/models/roroacms/menu_option.rb
roroacms-0.0.8.6.4 app/models/roroacms/menu_option.rb
roroacms-0.0.8.6.3 app/models/roroacms/menu_option.rb
roroacms-0.0.8.6.2 app/models/roroacms/menu_option.rb
roroacms-0.0.8.6.1 app/models/roroacms/menu_option.rb
roroacms-0.0.8.6 app/models/roroacms/menu_option.rb
roroacms-0.0.8.5 app/models/roroacms/menu_option.rb
roroacms-0.0.8.4 app/models/roroacms/menu_option.rb
roroacms-0.0.8.3 app/models/roroacms/menu_option.rb
roroacms-0.0.8.2 app/models/roroacms/menu_option.rb
roroacms-0.0.8.1 app/models/roroacms/menu_option.rb
roroacms-0.0.8 app/models/roroacms/menu_option.rb
roroacms-0.0.7.10 app/models/roroacms/menu_option.rb
roroacms-0.0.7.8 app/models/roroacms/menu_option.rb
roroacms-0.0.7.7 app/models/roroacms/menu_option.rb
roroacms-0.0.7.6 app/models/roroacms/menu_option.rb
roroacms-0.0.7.5 app/models/roroacms/menu_option.rb