Class: Tests::AjaxesController

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

Instance Method Summary collapse

Methods included from SessionsHelper

#preferences_customer_type=, #preferences_customer_type?, #signed_in?, #signed_in_user, #store_location

Instance Method Details

#addObject



92
93
94
95
96
97
98
99
# File 'app/controllers/tests/ajaxes_controller.rb', line 92

def add
  respond_to do |format| 
    format.json do
      @ajax = Tests::Ajax.create!(name: (((Tests::Ajax.last ? Tests::Ajax.last.id : 0) + 1).to_s))
      all
    end
  end
end

#add_and_updateObject

test add and update



84
85
86
87
88
89
90
# File 'app/controllers/tests/ajaxes_controller.rb', line 84

def add_and_update
  
  respond_to do |format|
    format.html #
    format.json { head :no_content }
  end
end

#allObject



101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/controllers/tests/ajaxes_controller.rb', line 101

def all
  respond_to do |format|
    format.json do
      #@template.template_format = :html
      @content = render_to_string( :partial => "tests/ajaxes/list", :formats => :html, :layout => false, :locals => { ajaxes: Tests::Ajax.all })
      render :json => { success: true, content: @content }
    end
    format.js do
      render "all", :layout => false, :content_type => 'application/javascript'
    end
  end
end

#createObject

POST /tests/ajaxes POST /tests/ajaxes.json



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/tests/ajaxes_controller.rb', line 40

def create
  @ajaxes = Tests::Ajax.new(params[:tests_ajaxis])

  respond_to do |format|
    if @ajaxes.save
      format.html { redirect_to @ajaxes, notice: 'Ajax was successfully created.' }
      format.json { render json: @ajaxes, status: :created, location: @ajaxes }
    else
      format.html { render action: "new" }
      format.json { render json: @ajaxes.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /tests/ajaxes/1 DELETE /tests/ajaxes/1.json



72
73
74
75
76
77
78
79
80
# File 'app/controllers/tests/ajaxes_controller.rb', line 72

def destroy
  @ajaxes = Tests::Ajax.find(params[:id])
  @ajaxes.destroy

  respond_to do |format|
    format.html { redirect_to tests_ajaxes_url }
    format.json { head :no_content }
  end
end

#editObject

GET /tests/ajaxes/1/edit



35
36
# File 'app/controllers/tests/ajaxes_controller.rb', line 35

def edit
end

#indexObject



7
8
9
10
11
12
# File 'app/controllers/tests/ajaxes_controller.rb', line 7

def index
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @ajaxes }
  end
end

#newObject

GET /tests/ajaxes/new GET /tests/ajaxes/new.json



26
27
28
29
30
31
32
# File 'app/controllers/tests/ajaxes_controller.rb', line 26

def new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @ajaxes }
  end
end

#showObject

GET /tests/ajaxes/1 GET /tests/ajaxes/1.json



16
17
18
19
20
21
22
# File 'app/controllers/tests/ajaxes_controller.rb', line 16

def show

  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @ajaxes }
  end
end

#updateObject

PUT /tests/ajaxes/1 PUT /tests/ajaxes/1.json



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/tests/ajaxes_controller.rb', line 56

def update
  @ajaxes = Tests::Ajax.find(params[:id])

  respond_to do |format|
    if @ajaxes.update_attributes(params[:tests_ajaxis])
      format.html { redirect_to @ajaxes, notice: 'Ajax was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @ajaxes.errors, status: :unprocessable_entity }
    end
  end
end