Sha256: 0a401dee09060d88b923afc45304ca25eed2363346963dc5ba1995c70ada9493

Contents?: true

Size: 1.4 KB

Versions: 18

Compression:

Stored size: 1.4 KB

Contents

# -*- encoding : utf-8 -*-
<%

  class_name = @conducer_name.camelize
  model_name = class_name.sub(/Conducer/, '') 

-%>

class <%= class_name %> < Dao::Conducer
  def initialize(user, model, params = {})
    @user = user
    @model = model

    update_attributes(
      :user  => @user.attributes,
      :model => @model.attributes,

      :foo  => 'bar'
    )

    id!(@model.id) unless @model.new_record?

    mount(Dao::Upload, :logo, :placeholder => (@model.logo.try(:url) || 'http://placeholder.com/image.png'))

    case action
      when 'new', 'create'
        @attributes.email = @user.email
        @model.field = @page.field

        update_attributes(params)

      when 'edit', 'update', 'show'
        @attributes.email = @user.email
        @model.field = @page.field

        update_attributes(params)
    end
  end


  validates_presence_of :something

  def save
    return(false) unless valid?

    raise NotImplementedError, <<-__
      this needs to
        - persist data to the db and get a new id
        - set the id on the object : @attributes.set(:id => id)
        - return true or false
    __

    true
  end

  def destroy
    id = self.id
    if id

      raise NotImplementedError, <<-__
        this needs to
          - un-persist data from the db
          - set the id on the object to nil : @attributes.rm(:id)
          - return this id of the destroyed object 
      __

    end
    id
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dao-8.0.1 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-8.0.0 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-7.0.0 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.6.1 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.5.2 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.5.1 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.5.0 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.4.0 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.3.3 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.3.2 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.3.0 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.2.1 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.1.2 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.1.1 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-5.0.0 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-4.6.4 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-4.4.4 lib/dao/rails/lib/generators/dao/templates/conducer.rb
dao-4.4.2 lib/dao/rails/lib/generators/dao/templates/conducer.rb