Class: KindsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #allow_cors, #allow_screen_if_unsecured, #apply_relative_root, #auth!, #check_for_initial_install, #compute_pending_moderation, #current_ability, #current_accessor, #current_screen, #extract_pagination_from_relation, #http_basic_user_name_and_password, #precompile_error_catch, #process_notification, #reapply_pagination, #restart_webserver, #screen_api, #set_locale, #set_time_zone, #set_version, #sign_in_screen, #sign_out_screen, #switch_to_main_app_ability, #switch_to_plugin_ability, #use_plugin_ability, #webserver_supports_restart?

Instance Method Details

#createObject

POST /kinds POST /kinds.xml



38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/kinds_controller.rb', line 38

def create
  @kind = Kind.new(kind_params)
  auth!
  
  if @kind.save
    flash[:notice] = t(:kind_created)
  end
  
  respond_with(@kind)

end

#destroyObject

DELETE /kinds/1 DELETE /kinds/1.xml



64
65
66
67
68
69
# File 'app/controllers/kinds_controller.rb', line 64

def destroy
  @kind = Kind.find(params[:id])
  auth!
  @kind.destroy
  respond_with(:kind)
end

#editObject

GET /kinds/1/edit



31
32
33
34
# File 'app/controllers/kinds_controller.rb', line 31

def edit
  @kind = Kind.find(params[:id])
  auth!
end

#indexObject

GET /kinds GET /kinds.xml



6
7
8
9
10
# File 'app/controllers/kinds_controller.rb', line 6

def index
  authorize! :read, Kind
  @kinds = Kind.all
  respond_with(:kinds)
end

#newObject

GET /kinds/new GET /kinds/new.xml



24
25
26
27
28
# File 'app/controllers/kinds_controller.rb', line 24

def new
  @kind = Kind.new
  auth!
  respond_with(:kind)
end

#showObject

GET /kinds/1 GET /kinds/1.xml



14
15
16
17
18
19
20
# File 'app/controllers/kinds_controller.rb', line 14

def show
  @kind = Kind.find(params[:id])
  auth!
  respond_with(@kind) do |format|
    format.xml { render :xml => @kind.to_xml(:include => [:fields]) }
  end
end

#updateObject

PUT /kinds/1 PUT /kinds/1.xml



52
53
54
55
56
57
58
59
60
# File 'app/controllers/kinds_controller.rb', line 52

def update
  @kind = Kind.find(params[:id])
  auth!
  
  if @kind.update_attributes(kind_params)
    flash[:notice] = t(:kind_updated)
  end
  respond_with(@kind)
end