Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## prints_controller.rb
- def roster
- @courses = Course.find(params[:cid])
- @registers = Register.find(:all, :joins => "inner join users on registers.user_id = users.id", :order => "lname ASC", :conditions => { :course_id => params[:cid] })
- col_counter = 0
- page_counter = 0
- data_counter = 0
- data = []
- data1 = []
- data2 = []
- data3 = []
- course = Course.find(params[:cid])
- if course.course_type_id
- ct = CourseType.find(course.course_type_id)
- end
- title1 = "Saint Louis University "
- if @courses && @courses.course_type.course_type.include?("Masters")
- title1 += @courses.course_type.course_type.to_s + " Conference"
- else
- title1 += "Medicolegal Death Investigator's Course"
- end
- if Date.today < @courses.start_date
- title2 = "Pre-Registration Class List"
- else
- title2 = "Final Registration Class List"
- end
- if @courses.start_date and @courses.end_date
- title3 = @courses.start_date.strftime("%b %d, %Y") + " - " + @courses.end_date.strftime("%b %d, %Y")
- end
- pdf = PDF::Writer.new
- pdf.select_font "Times-Roman"
- table = PDF::SimpleTable.new
- table.title = ""
- table.column_order.push(*%w(heading))
- table.columns["heading"] = PDF::SimpleTable::Column.new("heading")
- table.columns["heading"].width = 308
- table.show_lines = :all
- table.show_headings = false
- table.position = :center
- table.orientation = :center
- table.font_size = 16
- table.shade_rows = :none
- table.row_gap = 10
- table.width = 308
- data = [
- {"heading" => title1},
- ]
- table.data.replace data
- table.render_on(pdf)
- table = PDF::SimpleTable.new
- table.title = ""
- table.column_order.push(*%w(heading))
- table.columns["heading"] = PDF::SimpleTable::Column.new("heading")
- table.columns["heading"].width = 195
- table.show_lines = :all
- table.show_headings = false
- table.position = :center
- table.orientation = :center
- table.font_size = 16
- table.shade_rows = :none
- table.row_gap = 10
- table.width = 195
- data = [
- {"heading" => title2},
- ]
- table.data.replace data
- table.render_on(pdf)
- table = PDF::SimpleTable.new
- table.title = ""
- table.column_order.push(*%w(heading))
- table.columns["heading"] = PDF::SimpleTable::Column.new("heading")
- table.columns["heading"].width = 140
- table.show_lines = :all
- table.show_headings = false
- table.position = :center
- table.orientation = :center
- table.font_size = 12
- table.shade_rows = :none
- table.row_gap = 10
- table.width = 140
- data = [
- {"heading" => title3},
- {"heading" => ""},
- {"heading" => ""},
- ]
- table.data.replace data
- table.render_on(pdf)
- table = PDF::SimpleTable.new
- table.title = ""
- table.column_order.push(*%w(first second third))
- table.columns["first"] = PDF::SimpleTable::Column.new("first")
- table.columns["first"].width = 166
- table.columns["second"] = PDF::SimpleTable::Column.new("second")
- table.columns["second"].width = 166
- table.columns["third"] = PDF::SimpleTable::Column.new("third")
- table.columns["third"].width = 166
- table.show_lines = :all
- table.show_headings = false
- table.position = :right
- table.orientation = :left
- table.font_size = 12
- table.shade_rows = :none
- table.row_gap = 10
- table.width = 500
- for registrant in @registers
- data_counter = 0
- if !registrant.user.address2.blank?
- address = registrant.user.address1 + " " + registrant.user.address2
- else
- address = registrant.user.address1
- end
- state_abbr = State.find(registrant.user.state).stateab
- if col_counter % 3 == 0
- page_counter += 1
- data = data1
- elsif col_counter % 3 == 1
- column = "second"
- else
- column = "third"
- end
- if !registrant.user.employer.nil? && registrant.user.employer.blank?
- data_counter += 1
- end
- if !registrant.user.phone1.blank?
- data_counter += 2
- end
- if !registrant.user.email.blank?
- data_counter += 4
- end
- if data_counter == 1
- data = [
- {column => registrant.user.fname + " " + registrant.user.lname},
- {column => registrant.user.employer},
- {column => address},
- {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
- ]
- elsif data_counter == 2
- data = [
- {column => registrant.user.fname + " " + registrant.user.lname},
- {column => address},
- {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
- {column => registrant.user.phone1},
- ]
- elsif data_counter == 3
- data = [
- {column => registrant.user.fname + " " + registrant.user.lname},
- {column => registrant.user.employer},
- {column => address},
- {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
- {column => registrant.user.phone1},
- ]
- elsif data_counter == 5
- data = [
- {column => registrant.user.fname + " " + registrant.user.lname},
- {column => registrant.user.employer},
- {column => address},
- {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
- {column => registrant.user.email},
- ]
- elsif data_counter == 6
- data = [
- {column => registrant.user.fname + " " + registrant.user.lname},
- {column => address},
- {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
- {column => registrant.user.phone1},
- {column => registrant.user.email},
- ]
- elsif data_counter == 7
- data = [
- {column => registrant.user.fname + " " + registrant.user.lname},
- {column => registrant.user.employer},
- {column => address},
- {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
- {column => registrant.user.phone1},
- {column => registrant.user.email},
- ]
- end
- if col_counter % 3 == 0
- data1 = data
- elsif col_counter % 3 == 1
- data2 = data
- else
- data3 = data
- end
- if page_counter % 6 == 0 && col_counter != 0
- pdf.start_new_page
- end
- col_counter += 1
- if col_counter % 3 == 0
- data << data1 << data2 << data3
- table.data.replace data
- table.render_on(pdf)
- end
- end
- table.data.replace data
- table.render_on(pdf)
- send_data pdf.render, :filename => 'certs.pdf', :type => "application/pdf", :disposition => 'inline'
- end
- ## error
- TypeError in PrintsController#roster
- can't convert String into Integer
- RAILS_ROOT: /home/tim/Code/slu
- Application Trace | Framework Trace | Full Trace
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:780:in `[]'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:780:in `__find_table_max_width__'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb:32:in `each'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb:32:in `each'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:779:in `__find_table_max_width__'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:778:in `each'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:778:in `__find_table_max_width__'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:260:in `render_on'
- app/controllers/prints_controller.rb:238:in `roster'
- app/controllers/prints_controller.rb:146:in `each'
- app/controllers/prints_controller.rb:146:in `roster'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
- vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `send'
- vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `perform_action_without_filters'
- vendor/rails/actionpack/lib/action_controller/filters.rb:580:in `call_filters'
- vendor/rails/actionpack/lib/action_controller/filters.rb:573:in `perform_action_without_benchmark'
- vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
- /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
- vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
- vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
- vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
- vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
- vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
- vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
- vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
- vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
- vendor/rails/actionpack/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
- vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
- vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
- vendor/rails/railties/lib/commands/servers/mongrel.rb:64
- /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
- /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
- vendor/rails/railties/lib/commands/server.rb:39
- script/server:3:in `require'
- script/server:3
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:780:in `[]'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:780:in `__find_table_max_width__'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb:32:in `each'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb:32:in `each'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:779:in `__find_table_max_width__'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:778:in `each'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:778:in `__find_table_max_width__'
- /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:260:in `render_on'
- app/controllers/prints_controller.rb:238:in `roster'
- app/controllers/prints_controller.rb:146:in `each'
- app/controllers/prints_controller.rb:146:in `roster'
- vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `send'
- vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `perform_action_without_filters'
- vendor/rails/actionpack/lib/action_controller/filters.rb:580:in `call_filters'
- vendor/rails/actionpack/lib/action_controller/filters.rb:573:in `perform_action_without_benchmark'
- vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
- /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
- vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
- vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
- vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
- vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
- vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
- vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
- vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
- vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
- vendor/rails/actionpack/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
- vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
- vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
- vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
- /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
- vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
- vendor/rails/railties/lib/commands/servers/mongrel.rb:64
- /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
- /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
- vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
- vendor/rails/railties/lib/commands/server.rb:39
- script/server:3:in `require'
- script/server:3
- Request
- Parameters:
- {"cid"=>"4"}
- Show session dump
- ---
- :user: !ruby/object:User
- attributes:
- salt:
- city:
- address1:
- created_at:
- zip:
- address2:
- hashedpassword:
- title:
- hashedanswer:
- job_title:
- updated_at:
- secret_question:
- admin: true
- id: 3
- phone1:
- lname:
- other_location:
- phone2:
- mi:
- county_id:
- employer:
- suffix:
- fname:
- active: true
- email:
- state:
- attributes_cache: {}
- changed_attributes:
- admin: false
- id:
- new_record: true
- flash: !map:ActionController::Flash::FlashHash {}
- Response
- Headers:
- {"cookie"=>[],
- "Cache-Control"=>"no-cache"}
Add Comment
Please, Sign In to add comment