Sha256: b6146e6e190c72efbc38234d16126f4409159de94b8b4aa2f16a9c42b64af357

Contents?: true

Size: 861 Bytes

Versions: 8

Compression:

Stored size: 861 Bytes

Contents

class AliasesController < ApplicationController

  before_filter :find_alias, :only => [:update]

  def update
    if @alias.update_attributes(params[:virtual_alias])
      render :json => {:id => @alias.id}
    else
      render :json => {:errors => @alias.errors.to_json}
    end
  rescue
    render :json => {:errors => t('unknown_error')}
  end

  def create
    @domain = current_admin_user.domain(params[:domain_id])
    @alias = @domain.virtual_aliases.build(params[:virtual_alias])
    if @alias.save
      render :json => {:id => @alias.id}
    else
      render :json => {:errors => @alias.errors.to_json}
    end
  rescue
    render :json => {:errors => t('unknown_error')}
  end


protected

  def find_alias
    @domain = current_admin_user.domain(params[:domain_id])
    @alias = @domain.virtual_aliases.where(:id => params[:id]).first
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rmails-0.2.1 app/controllers/aliases_controller.rb
rmails-0.2.0 app/controllers/aliases_controller.rb
rmails-0.1.6 app/controllers/aliases_controller.rb
rmails-0.1.5 app/controllers/aliases_controller.rb
rmails-0.1.4 app/controllers/aliases_controller.rb
rmails-0.1.3 app/controllers/aliases_controller.rb
rmails-0.1.2 app/controllers/aliases_controller.rb
rmails-0.1.1 app/controllers/aliases_controller.rb