Class: AddressesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- AddressesController
- Defined in:
- lib/rails/generators/simple_address_generator/templates/addresses_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /addresses POST /addresses.json.
-
#destroy ⇒ Object
DELETE /addresses/1 DELETE /addresses/1.json.
-
#edit ⇒ Object
GET /addresses/1/edit.
-
#index ⇒ Object
GET /addresses GET /addresses.json.
-
#new ⇒ Object
GET /addresses/new GET /addresses/new.json.
-
#show ⇒ Object
GET /addresses/1 GET /addresses/1.json.
-
#update ⇒ Object
PUT /addresses/1 PUT /addresses/1.json.
Instance Method Details
#create ⇒ Object
POST /addresses POST /addresses.json
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rails/generators/simple_address_generator/templates/addresses_controller.rb', line 44 def create @address = Address.new(params[:address]) respond_to do |format| if @address.save format.html { redirect_to @address, notice: 'Address was successfully created.' } format.json { render json: @address, status: :created, location: @address } else format.html { render action: "new" } format.json { render json: @address.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /addresses/1 DELETE /addresses/1.json
76 77 78 79 80 81 82 83 84 |
# File 'lib/rails/generators/simple_address_generator/templates/addresses_controller.rb', line 76 def destroy @address = Address.find(params[:id]) @address.destroy respond_to do |format| format.html { redirect_to addresses_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /addresses/1/edit
38 39 40 |
# File 'lib/rails/generators/simple_address_generator/templates/addresses_controller.rb', line 38 def edit @address = Address.find(params[:id]) end |
#index ⇒ Object
GET /addresses GET /addresses.json
4 5 6 7 8 9 10 11 12 |
# File 'lib/rails/generators/simple_address_generator/templates/addresses_controller.rb', line 4 def index @addresses = Address.all @json = @addresses.to_gmaps4rails respond_to do |format| format.html # index.html.erb format.json { render json: @addresses } end end |
#new ⇒ Object
GET /addresses/new GET /addresses/new.json
28 29 30 31 32 33 34 35 |
# File 'lib/rails/generators/simple_address_generator/templates/addresses_controller.rb', line 28 def new @address = Address.new respond_to do |format| format.html # new.html.erb format.json { render json: @address } end end |
#show ⇒ Object
GET /addresses/1 GET /addresses/1.json
16 17 18 19 20 21 22 23 24 |
# File 'lib/rails/generators/simple_address_generator/templates/addresses_controller.rb', line 16 def show @address = Address.find(params[:id]) @json = @address.to_gmaps4rails respond_to do |format| format.html # show.html.erb format.json { render json: @address } end end |
#update ⇒ Object
PUT /addresses/1 PUT /addresses/1.json
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rails/generators/simple_address_generator/templates/addresses_controller.rb', line 60 def update @address = Address.find(params[:id]) respond_to do |format| if @address.update_attributes(params[:address]) format.html { redirect_to @address, notice: 'Address was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @address.errors, status: :unprocessable_entity } end end end |