Class: Phcscriptcdnpro::Script::UrlsController

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



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/phcscriptcdnpro/script/urls_controller.rb', line 37

def create
  @script_listing = Script::Listing.find(params[:listing_id])
  @script_url = @script_listing.urls.create(script_url_params)
  @script_url.user_id = current_user.id
  @script_url.user_name = current_user.username
  @script_url.membership_id = authrocket_membership_info.id
  @script_url.oganization_id = authrocket_membership_info.org_id
  if @script_url.save
    redirect_to script_listing_urls_path, notice: 'Author was successfully created.'
    else
      render :new
  end
end

#destroyObject

DELETE - Script Athors



65
66
67
68
69
70
# File 'app/controllers/phcscriptcdnpro/script/urls_controller.rb', line 65

def destroy
  @script_listing = Script::Listing.find(params[:listing_id])
  @script_url = @script_listing.urls.find(params[:id])
  @script_url.destroy
  redirect_to script_listing_urls_path, notice: 'Author was successfully destroyed.'
end

#editObject

EDIT - Script Athors



31
32
33
34
# File 'app/controllers/phcscriptcdnpro/script/urls_controller.rb', line 31

def edit
  script_listing = Script::Listing.find(params[:listing_id])
  @script_url = script_listing.urls.find(params[:id])
end

#indexObject

INDEX - Script Authors



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

def index
  script_listing = Script::Listing.find(params[:listing_id])
  @script_urls = script_listing.urls
end

#newObject

NEW - Script Athors



25
26
27
28
# File 'app/controllers/phcscriptcdnpro/script/urls_controller.rb', line 25

def new
  script_listing = Script::Listing.find(params[:listing_id])
  @script_url = script_listing.urls.build
end

#showObject

DETAILED PROFILE - Script Authors



19
20
21
22
# File 'app/controllers/phcscriptcdnpro/script/urls_controller.rb', line 19

def show
  script_listing = Script::Listing.find(params[:listing_id])
  @script_url = script_listing.urls.friendly.find(params[:id])
end

#updateObject

PATCH/PUT - Script Athors



52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/phcscriptcdnpro/script/urls_controller.rb', line 52

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