Class: WebsitesController

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

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_user, #current_user Used for unit testing, this is normally managed by Devise

Instance Method Summary collapse

Methods inherited from ApplicationController

#clear_search_index, #search_params

Instance Method Details

#check_countObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/websites_controller.rb', line 22

def check_count
  @our_count = @website.images.count
  @their_count = 0

  uniqs = @website.strategy_check_count
  @their_count = uniqs.count

  our_c_ids = @website.images.collect{|i| i.canonical_id}
  @our_count = @website.images.count

  @our_matched_ids = uniqs & our_c_ids
  @our_unmatched_ids =  our_c_ids - uniqs
  @their_unmatched_ids = uniqs - our_c_ids
end

#createObject

POST /websites



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/websites_controller.rb', line 47

def create
  @website = Website.new(website_params)

  if @website.save
    if request.format.html?
      redirect_to @website, notice: 'Website was successfully created.'
    else
      render :json => @website.to_json
    end
  else
    if request.format.html?
      render :new
    else
      render :json => { :errors => @website.errors.full_messages }
    end
  end
end

#destroyObject

DELETE /websites/1



83
84
85
86
# File 'app/controllers/websites_controller.rb', line 83

def destroy
  @website.destroy
  redirect_to websites_url, notice: 'Website was successfully destroyed.'
end

#editObject

GET /websites/1/edit



43
44
# File 'app/controllers/websites_controller.rb', line 43

def edit
end

#indexObject



13
14
15
# File 'app/controllers/websites_controller.rb', line 13

def index
  @websites = Website.all
end

#newObject

GET /websites/new



38
39
40
# File 'app/controllers/websites_controller.rb', line 38

def new
  @website = Website.new
end

#showObject



19
20
# File 'app/controllers/websites_controller.rb', line 19

def show
end

#updateObject

PATCH/PUT /websites/1



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/websites_controller.rb', line 66

def update
  if @website.update(website_params)
    if request.format.html?
      redirect_to @website, notice: 'Website was successfully updated.'
    else
      render @website
    end
  else
    if request.format.html?
      render :edit
    else
      render :json => { :errors => @website.errors.full_messages }
    end
  end
end