Class: AuthorsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- AuthorsController
- Defined in:
- app/controllers/authors_controller.rb
Instance Method Summary (collapse)
- - (Object) add_blank_panel_if_necessary
- - (Object) all
- - (Object) create_panels
- - (Object) index
- - (Object) merge
Instance Method Details
- (Object) add_blank_panel_if_necessary
30 31 32 |
# File 'app/controllers/authors_controller.rb', line 30 def add_blank_panel_if_necessary @panels << OpenStruct.new(term: '') unless @panels.find{|panel| !panel.} end |
- (Object) all
45 46 47 48 49 50 |
# File 'app/controllers/authors_controller.rb', line 45 def all respond_to do |format| format.json {render :json => AuthorName.search(params[:term]).to_json} format.html end end |
- (Object) create_panels
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/authors_controller.rb', line 11 def create_panels params[:terms] ||= [] # if closing a panel, remove its term params[:terms].delete params[:term] unless params[:commit] @panels = [] @authors = [] for term in params[:terms] panel = OpenStruct.new term: term.strip, author: Author.find_by_names(term).first @panels << panel next unless panel. panel.already_open = @authors.include? panel. panel. = nil if panel.already_open @authors << panel. if panel. end @names = @authors.map(&:names).flatten.map(&:name).uniq end |
- (Object) index
6 7 8 9 |
# File 'app/controllers/authors_controller.rb', line 6 def index create_panels add_blank_panel_if_necessary end |
- (Object) merge
35 36 37 38 39 40 41 42 |
# File 'app/controllers/authors_controller.rb', line 35 def merge term = params[:terms].first create_panels Author.merge @authors params[:terms] = [term] index render :index end |