Class: Phcscriptcdnpro::Script::ListingsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#user_for_paper_trail

Instance Method Details

#createObject

POST - Script Listings



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

def create
  @script_listing = Script::Listing.new(script_listing_params)
  @script_listing.user_id = current_user.id
  @script_listing.org_id = current_user.org_id
  if @script_listing.save
    redirect_to script_listings_path, notice: 'Listing was successfully created.'
    else
      render :new
  end
end

#destroyObject

DELETE - Script Listings



57
58
59
60
# File 'app/controllers/phcscriptcdnpro/script/listings_controller.rb', line 57

def destroy
  @script_listing.destroy
  redirect_to script_listings_path, notice: 'Listing was successfully destroyed.'
end

#editObject

EDIT - Script Listings



30
31
# File 'app/controllers/phcscriptcdnpro/script/listings_controller.rb', line 30

def edit
end

#indexObject

INDEX - Script Listings



12
13
14
# File 'app/controllers/phcscriptcdnpro/script/listings_controller.rb', line 12

def index
  @script_listings = Script::Listing.where(org_id: current_user.org_id)
end

#newObject

NEW - Script Listings



23
24
25
26
27
# File 'app/controllers/phcscriptcdnpro/script/listings_controller.rb', line 23

def new
  @script_listing = Script::Listing.new
  @script_listing.user_id = current_user.id
  @script_listing.org_id = current_user.org_id
end

#showObject

DETAILS - Script Listings



17
18
19
20
# File 'app/controllers/phcscriptcdnpro/script/listings_controller.rb', line 17

def show
  @script_listings = Script::Listing.friendly.find(params[:id])
  @versions = Phcscriptcdnpro::ListingVersions.where(item_id: params[:id], item_type: 'Phcscriptcdnpro::Script::Listing')
end

#updateObject

PATCH/PUT - Script Listings



46
47
48
49
50
51
52
53
54
# File 'app/controllers/phcscriptcdnpro/script/listings_controller.rb', line 46

def update
  @script_listing.user_id = current_user.id
  @script_listing.org_id = current_user.org_id
  if @script_listing.update(script_listing_params)
    redirect_to script_listings_path, notice: 'Listing was successfully updated.'
  else
    render :edit
  end
end