Class: Phcscriptcdnpro::Script::AuthorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/phcscriptcdnpro/script/authors_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

CREATE - Script Author



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

def create
  @script_author = Script::Author.new(script_author_params)
  @script_author.user_id = current_user.id
  @script_author.user_name = current_user.username
  @script_author.membership_id = authrocket_membership_info.id
  @script_author.oganization_id = authrocket_membership_info.org_id
  if @script_author.save
    redirect_to script_authors_url, notice: 'Author was successfully created.'
    else
    render :new
  end
end

#destroyObject

DELETE - Script Author



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

def destroy
  @script_author.destroy
  redirect_to script_authors_url, notice: 'Author was successfully destroyed.'
end

#editObject

EDIT - Script Author



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

def edit
end

#indexObject

INDEX - Script Author



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

def index
  @script_authors = Script::Author.where(oganization_id: authrocket_membership_info.org_id)
end

#newObject

NEW - Script Author



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

def new
  @script_author = Script::Author.new
end

#showObject

DETAILS - Script Author



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

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

#updateObject

PATCH/PUT - Script Author



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

def update
  @script_author.user_id = current_user.id
  @script_author.user_name = current_user.username
  @script_author.membership_id = authrocket_membership_info.id
  @script_author.oganization_id = authrocket_membership_info.org_id
  if @script_author.update(script_author_params)
      redirect_to script_authors_url, notice: 'Author was successfully updated.'
      else
        render :edit
  end
end