Class: AddressSearchesController

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

Overview

typed: false

Instance Method Summary collapse

Methods inherited from ApplicationController

#gdpr_compliance

Instance Method Details

#createObject

POST /address_searches POST /address_searches.json



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/address_searches_controller.rb', line 29

def create
  @address_search = AddressSearch.new(address_search_params)

  respond_to do |format|
    if @address_search.save
      format.html { redirect_to @address_search, notice: 'Address search was successfully created.' }
      format.json { render :show, status: :created, location: @address_search }
    else
      format.html { render :new }
      format.json { render json: @address_search.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /address_searches/1 DELETE /address_searches/1.json



59
60
61
62
63
64
65
# File 'app/controllers/address_searches_controller.rb', line 59

def destroy
  @address_search.destroy
  respond_to do |format|
    format.html { redirect_to address_searches_url, notice: 'Address search was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /address_searches/1/edit



24
25
# File 'app/controllers/address_searches_controller.rb', line 24

def edit
end

#indexObject

GET /address_searches GET /address_searches.json



7
8
9
# File 'app/controllers/address_searches_controller.rb', line 7

def index
  @address_searches = AddressSearch.all
end

#newObject

GET /address_searches/new



19
20
21
# File 'app/controllers/address_searches_controller.rb', line 19

def new
  @address_search = AddressSearch.new
end

#showObject

GET /address_searches/1 GET /address_searches/1.json



13
14
15
16
# File 'app/controllers/address_searches_controller.rb', line 13

def show
  search_url = "https://seeiendom.kartverket.no/api/soekEtterEiendom?searchstring=#{CGI.escape(@address_search.search_string)}"
  @search_result_json = HTTParty.get(search_url)
end

#updateObject

PATCH/PUT /address_searches/1 PATCH/PUT /address_searches/1.json



45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/address_searches_controller.rb', line 45

def update
  respond_to do |format|
    if @address_search.update(address_search_params)
      format.html { redirect_to @address_search, notice: 'Address search was successfully updated.' }
      format.json { render :show, status: :ok, location: @address_search }
    else
      format.html { render :edit }
      format.json { render json: @address_search.errors, status: :unprocessable_entity }
    end
  end
end