Sha256: b10c084f85bc5ad94d7f6610d284499e3558a18931ddfca6c979ec449b7bbbf3

Contents?: true

Size: 1.98 KB

Versions: 8

Compression:

Stored size: 1.98 KB

Contents

# coding utf-8

require_dependency "adherent/application_controller"

module Adherent
  class CoordsController < ApplicationController
    
    before_filter :find_member, :except=>[:index]
   
    # GET /coords/1
    # GET /coords/1.json
    def show
      @coord = @member.coord 
      unless @coord
        flash[:alert] = "Pas encore de coordonnées pour #{@member.to_s}"
        redirect_to new_member_coord_url(@member) and return
      end   
      respond_to do |format|
        format.html # show.html.erb
        format.json { render json: @coord }
      end
    end
  
    # GET /coords/new
    # GET /coords/new.json
    def new
      @coord = @member.build_coord
  
      respond_to do |format|
        format.html # new.html.erb
        format.json { render json: @coord }
      end
    end
  
    # GET /coords/1/edit
    def edit
      @coord = @member.coord
    end
  
    # POST /coords
    # POST /coords.json
    def create
      @coord = @member.build_coord(params[:coord])
  
      respond_to do |format|
        if @coord.save
          format.html { redirect_to new_member_adhesion_url(@member), notice: 'Coordonnées enregistrées' }
          format.json { render json: @coord, status: :created, location: @coord }
        else
          format.html { render action: "new" }
          format.json { render json: @coord.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PUT /coords/1
    # PUT /coords/1.json
    def update
      @coord = @member.coord
  
      respond_to do |format|
        if @coord.update_attributes(params[:coord])
          format.html { redirect_to member_coord_path(@member), notice: 'Coordonnées mises à jour' }
          format.json { head :no_content }
        else
          format.html { render action: "edit" }
          format.json { render json: @coord.errors, status: :unprocessable_entity }
        end
      end
    end
  
    
    
    protected 
    
    def find_member
      @member = Member.find(params[:member_id])
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
adherent-0.1.10 app/controllers/adherent/coords_controller.rb
adherent-0.1.9 app/controllers/adherent/coords_controller.rb
adherent-0.1.7 app/controllers/adherent/coords_controller.rb
adherent-0.1.6 app/controllers/adherent/coords_controller.rb
adherent-0.1.5 app/controllers/adherent/coords_controller.rb
adherent-0.1.4 app/controllers/adherent/coords_controller.rb
adherent-0.1.3 app/controllers/adherent/coords_controller.rb
adherent-0.1.2 app/controllers/adherent/coords_controller.rb