Class: PublishersController

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

Instance Method Summary collapse

Instance Method Details

#createObject


27
28
29
30
31
32
# File 'app/controllers/publishers_controller.rb', line 27

def create
  @publisher = Publisher.new(publisher_params)
  authorize @publisher
  @publisher.save
  respond_with(@publisher)
end

#destroyObject


39
40
41
42
# File 'app/controllers/publishers_controller.rb', line 39

def destroy
  @publisher.destroy
  respond_with(@publisher)
end

#editObject


24
25
# File 'app/controllers/publishers_controller.rb', line 24

def edit
end

#indexObject


6
7
8
9
# File 'app/controllers/publishers_controller.rb', line 6

def index
  @publishers = policy_scope(Publisher).page(params[:page])
  respond_with(@publishers)
end

#newObject


18
19
20
21
22
# File 'app/controllers/publishers_controller.rb', line 18

def new
  @publisher = Publisher.new
  authorize @publisher
  respond_with(@publisher)
end

#searchObject


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

def search
  authorize :publisher, :search?
  if params[:query].present?
    respond_to do |format|

      format.html do
        @publishers = Publisher.search(params[:query],fields: [{'name' => :word_start}, 'owner'], page: params[:page], per_page: 25)                
        render :index          
      end

      format.json do
        @publishers = Publisher.search(params[:query],fields: [{'name' => :word_start}], limit: 10).map(&:name)
        render json: @publishers 
      end

    end  
  else
    redirect_to(publishers_url)
  end
end

#showObject


11
12
13
14
15
16
# File 'app/controllers/publishers_controller.rb', line 11

def show
  @placeable = @publisher
  @places = @placeable.places
  @place = Place.new
  respond_with(@publisher)
end

#updateObject


34
35
36
37
# File 'app/controllers/publishers_controller.rb', line 34

def update
  @publisher.update(publisher_params)
  respond_with(@publisher)
end