Class: Ishapi::AddressesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ishapi/addresses_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home, #long_term_token, #test

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/ishapi/addresses_controller.rb', line 7

def create
  if @current_profile.addresses.length == 0
    @address = CoTailors::Address.new({ :profile_id => @current_profile.id })
  else
    @address = @current_profile.addresses[0]
  end
  authorize! :update, @address
  flag = @address.update_attributes( params[:address].permit(:name, :phone, :address_1, :address_2, :city, :state, :zipcode ) )
  if flag
    render :json => { :status => :ok, :message => 'Successfully put an address.' }
  else
    render :json => { :status => :not_ok, :error => @address.errors.messages }
  end
end