Class: Phcscriptcdnpro::Script::LicencesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/phcscriptcdnpro/script/licences_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authrocket_membership_info, #current_user, #new_login_url, #require_user, #user_for_paper_trail

Instance Method Details

#createObject

POST - Script Licences



33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/phcscriptcdnpro/script/licences_controller.rb', line 33

def create
  @script_licence = Script::Licence.new(script_licence_params)
  @script_licence.user_id = current_user.id
  @script_licence.user_name = current_user.username
  @script_licence.membership_id = authrocket_membership_info.id
  @script_licence.oganization_id = authrocket_membership_info.org_id
  if @script_licence.save
    redirect_to script_licences_url, notice: 'Licence was successfully created.'
    else
    render :new
  end
end

#destroyObject

DELETE - Script Licences



60
61
62
63
# File 'app/controllers/phcscriptcdnpro/script/licences_controller.rb', line 60

def destroy
  @script_licence.destroy
  redirect_to script_licences_url, notice: 'Licence was successfully destroyed.'
end

#editObject

EDIT - Script Licences



29
30
# File 'app/controllers/phcscriptcdnpro/script/licences_controller.rb', line 29

def edit
end

#indexObject

INDEX - Script Licences



13
14
15
# File 'app/controllers/phcscriptcdnpro/script/licences_controller.rb', line 13

def index
  @script_licences = Script::Licence.where(oganization_id: authrocket_membership_info.org_id)
end

#newObject

NEW - Script Licences



24
25
26
# File 'app/controllers/phcscriptcdnpro/script/licences_controller.rb', line 24

def new
  @script_licence = Script::Licence.new
end

#showObject

DETAILS - Script Licences



18
19
20
21
# File 'app/controllers/phcscriptcdnpro/script/licences_controller.rb', line 18

def show
  @script_licences = Script::Licence.friendly.find(params[:id])
  @versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcmemberspro::Directory::Category')
end

#updateObject

PATCH/PUT - Script Licences



47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/phcscriptcdnpro/script/licences_controller.rb', line 47

def update
  @script_licence.user_id = current_user.id
  @script_licence.user_name = current_user.username
  @script_licence.membership_id = authrocket_membership_info.id
  @script_licence.oganization_id = authrocket_membership_info.org_id
  if @script_licence.update(script_licence_params)
    redirect_to script_licences_url, notice: 'Licence was successfully updated.'
    else
      render :edit
  end
end