Guest User

Untitled

a guest
Jul 3rd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.91 KB | None | 0 0
  1. ## prints_controller.rb
  2. def roster
  3. @courses = Course.find(params[:cid])
  4. @registers = Register.find(:all, :joins => "inner join users on registers.user_id = users.id", :order => "lname ASC", :conditions => { :course_id => params[:cid] })
  5.  
  6. col_counter = 0
  7. page_counter = 0
  8. data_counter = 0
  9. data = []
  10. data1 = []
  11. data2 = []
  12. data3 = []
  13.  
  14. course = Course.find(params[:cid])
  15. if course.course_type_id
  16. ct = CourseType.find(course.course_type_id)
  17. end
  18.  
  19. title1 = "Saint Louis University "
  20. if @courses && @courses.course_type.course_type.include?("Masters")
  21. title1 += @courses.course_type.course_type.to_s + " Conference"
  22. else
  23. title1 += "Medicolegal Death Investigator's Course"
  24. end
  25.  
  26. if Date.today < @courses.start_date
  27. title2 = "Pre-Registration Class List"
  28. else
  29. title2 = "Final Registration Class List"
  30. end
  31.  
  32. if @courses.start_date and @courses.end_date
  33. title3 = @courses.start_date.strftime("%b %d, %Y") + " - " + @courses.end_date.strftime("%b %d, %Y")
  34. end
  35.  
  36. pdf = PDF::Writer.new
  37. pdf.select_font "Times-Roman"
  38. table = PDF::SimpleTable.new
  39. table.title = ""
  40. table.column_order.push(*%w(heading))
  41. table.columns["heading"] = PDF::SimpleTable::Column.new("heading")
  42. table.columns["heading"].width = 308
  43.  
  44. table.show_lines = :all
  45. table.show_headings = false
  46. table.position = :center
  47. table.orientation = :center
  48. table.font_size = 16
  49. table.shade_rows = :none
  50. table.row_gap = 10
  51. table.width = 308
  52.  
  53. data = [
  54. {"heading" => title1},
  55. ]
  56.  
  57. table.data.replace data
  58. table.render_on(pdf)
  59.  
  60.  
  61.  
  62. table = PDF::SimpleTable.new
  63. table.title = ""
  64. table.column_order.push(*%w(heading))
  65. table.columns["heading"] = PDF::SimpleTable::Column.new("heading")
  66. table.columns["heading"].width = 195
  67.  
  68. table.show_lines = :all
  69. table.show_headings = false
  70. table.position = :center
  71. table.orientation = :center
  72. table.font_size = 16
  73. table.shade_rows = :none
  74. table.row_gap = 10
  75. table.width = 195
  76.  
  77. data = [
  78. {"heading" => title2},
  79. ]
  80.  
  81. table.data.replace data
  82. table.render_on(pdf)
  83.  
  84.  
  85.  
  86.  
  87. table = PDF::SimpleTable.new
  88. table.title = ""
  89. table.column_order.push(*%w(heading))
  90. table.columns["heading"] = PDF::SimpleTable::Column.new("heading")
  91. table.columns["heading"].width = 140
  92.  
  93. table.show_lines = :all
  94. table.show_headings = false
  95. table.position = :center
  96. table.orientation = :center
  97. table.font_size = 12
  98. table.shade_rows = :none
  99. table.row_gap = 10
  100. table.width = 140
  101.  
  102. data = [
  103. {"heading" => title3},
  104. {"heading" => ""},
  105. {"heading" => ""},
  106. ]
  107.  
  108. table.data.replace data
  109. table.render_on(pdf)
  110.  
  111.  
  112.  
  113. table = PDF::SimpleTable.new
  114. table.title = ""
  115. table.column_order.push(*%w(first second third))
  116. table.columns["first"] = PDF::SimpleTable::Column.new("first")
  117. table.columns["first"].width = 166
  118. table.columns["second"] = PDF::SimpleTable::Column.new("second")
  119. table.columns["second"].width = 166
  120. table.columns["third"] = PDF::SimpleTable::Column.new("third")
  121. table.columns["third"].width = 166
  122.  
  123. table.show_lines = :all
  124. table.show_headings = false
  125. table.position = :right
  126. table.orientation = :left
  127. table.font_size = 12
  128. table.shade_rows = :none
  129. table.row_gap = 10
  130. table.width = 500
  131.  
  132. for registrant in @registers
  133. data_counter = 0
  134.  
  135. if !registrant.user.address2.blank?
  136. address = registrant.user.address1 + " " + registrant.user.address2
  137. else
  138. address = registrant.user.address1
  139. end
  140. state_abbr = State.find(registrant.user.state).stateab
  141. if col_counter % 3 == 0
  142. page_counter += 1
  143. data = data1
  144. elsif col_counter % 3 == 1
  145. column = "second"
  146. else
  147. column = "third"
  148. end
  149.  
  150. if !registrant.user.employer.nil? && registrant.user.employer.blank?
  151. data_counter += 1
  152. end
  153. if !registrant.user.phone1.blank?
  154. data_counter += 2
  155. end
  156. if !registrant.user.email.blank?
  157. data_counter += 4
  158. end
  159.  
  160. if data_counter == 1
  161. data = [
  162. {column => registrant.user.fname + " " + registrant.user.lname},
  163. {column => registrant.user.employer},
  164. {column => address},
  165. {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
  166. ]
  167. elsif data_counter == 2
  168. data = [
  169. {column => registrant.user.fname + " " + registrant.user.lname},
  170. {column => address},
  171. {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
  172. {column => registrant.user.phone1},
  173. ]
  174. elsif data_counter == 3
  175. data = [
  176. {column => registrant.user.fname + " " + registrant.user.lname},
  177. {column => registrant.user.employer},
  178. {column => address},
  179. {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
  180. {column => registrant.user.phone1},
  181. ]
  182. elsif data_counter == 5
  183. data = [
  184. {column => registrant.user.fname + " " + registrant.user.lname},
  185. {column => registrant.user.employer},
  186. {column => address},
  187. {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
  188. {column => registrant.user.email},
  189. ]
  190. elsif data_counter == 6
  191. data = [
  192. {column => registrant.user.fname + " " + registrant.user.lname},
  193. {column => address},
  194. {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
  195. {column => registrant.user.phone1},
  196. {column => registrant.user.email},
  197. ]
  198. elsif data_counter == 7
  199. data = [
  200. {column => registrant.user.fname + " " + registrant.user.lname},
  201. {column => registrant.user.employer},
  202. {column => address},
  203. {column => registrant.user.city + ", " + state_abbr + " " + registrant.user.zip},
  204. {column => registrant.user.phone1},
  205. {column => registrant.user.email},
  206. ]
  207. end
  208.  
  209. if col_counter % 3 == 0
  210. data1 = data
  211. elsif col_counter % 3 == 1
  212. data2 = data
  213. else
  214. data3 = data
  215. end
  216.  
  217. if page_counter % 6 == 0 && col_counter != 0
  218. pdf.start_new_page
  219. end
  220. col_counter += 1
  221. if col_counter % 3 == 0
  222. data << data1 << data2 << data3
  223. table.data.replace data
  224. table.render_on(pdf)
  225. end
  226. end
  227.  
  228. table.data.replace data
  229. table.render_on(pdf)
  230. send_data pdf.render, :filename => 'certs.pdf', :type => "application/pdf", :disposition => 'inline'
  231. end
  232.  
  233. ## error
  234. TypeError in PrintsController#roster
  235.  
  236. can't convert String into Integer
  237.  
  238. RAILS_ROOT: /home/tim/Code/slu
  239. Application Trace | Framework Trace | Full Trace
  240.  
  241. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:780:in `[]'
  242. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:780:in `__find_table_max_width__'
  243. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb:32:in `each'
  244. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb:32:in `each'
  245. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:779:in `__find_table_max_width__'
  246. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:778:in `each'
  247. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:778:in `__find_table_max_width__'
  248. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:260:in `render_on'
  249. app/controllers/prints_controller.rb:238:in `roster'
  250. app/controllers/prints_controller.rb:146:in `each'
  251. app/controllers/prints_controller.rb:146:in `roster'
  252. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
  253. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
  254. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
  255. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
  256. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
  257. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
  258. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
  259. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
  260. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
  261. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
  262. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
  263. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
  264. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
  265. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
  266. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
  267. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
  268. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
  269. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
  270. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
  271.  
  272. vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `send'
  273. vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `perform_action_without_filters'
  274. vendor/rails/actionpack/lib/action_controller/filters.rb:580:in `call_filters'
  275. vendor/rails/actionpack/lib/action_controller/filters.rb:573:in `perform_action_without_benchmark'
  276. vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  277. /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
  278. vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  279. vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
  280. vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
  281. vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
  282. vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
  283. vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
  284. vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
  285. vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
  286. vendor/rails/actionpack/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
  287. vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
  288. vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
  289. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
  290. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
  291. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
  292. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
  293. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
  294. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
  295. vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  296. vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  297. vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
  298. vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  299. vendor/rails/railties/lib/commands/servers/mongrel.rb:64
  300. /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
  301. /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  302. vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
  303. vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
  304. vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
  305. vendor/rails/railties/lib/commands/server.rb:39
  306. script/server:3:in `require'
  307. script/server:3
  308.  
  309. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:780:in `[]'
  310. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:780:in `__find_table_max_width__'
  311. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb:32:in `each'
  312. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb:32:in `each'
  313. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:779:in `__find_table_max_width__'
  314. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:778:in `each'
  315. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:778:in `__find_table_max_width__'
  316. /var/lib/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb:260:in `render_on'
  317. app/controllers/prints_controller.rb:238:in `roster'
  318. app/controllers/prints_controller.rb:146:in `each'
  319. app/controllers/prints_controller.rb:146:in `roster'
  320. vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `send'
  321. vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `perform_action_without_filters'
  322. vendor/rails/actionpack/lib/action_controller/filters.rb:580:in `call_filters'
  323. vendor/rails/actionpack/lib/action_controller/filters.rb:573:in `perform_action_without_benchmark'
  324. vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  325. /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
  326. vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  327. vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
  328. vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
  329. vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
  330. vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
  331. vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
  332. vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
  333. vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
  334. vendor/rails/actionpack/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
  335. vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
  336. vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
  337. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
  338. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
  339. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
  340. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
  341. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
  342. vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
  343. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
  344. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
  345. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
  346. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
  347. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
  348. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
  349. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
  350. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
  351. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
  352. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
  353. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
  354. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
  355. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
  356. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
  357. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
  358. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
  359. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
  360. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
  361. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
  362. vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  363. vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  364. vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
  365. vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  366. vendor/rails/railties/lib/commands/servers/mongrel.rb:64
  367. /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
  368. /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  369. vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
  370. vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
  371. vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
  372. vendor/rails/railties/lib/commands/server.rb:39
  373. script/server:3:in `require'
  374. script/server:3
  375.  
  376. Request
  377.  
  378. Parameters:
  379.  
  380. {"cid"=>"4"}
  381.  
  382. Show session dump
  383.  
  384. ---
  385. :user: !ruby/object:User
  386. attributes:
  387. salt:
  388. city:
  389. address1:
  390. created_at:
  391. zip:
  392. address2:
  393. hashedpassword:
  394. title:
  395. hashedanswer:
  396. job_title:
  397. updated_at:
  398. secret_question:
  399. admin: true
  400. id: 3
  401. phone1:
  402. lname:
  403. other_location:
  404. phone2:
  405. mi:
  406. county_id:
  407. employer:
  408. suffix:
  409. fname:
  410. active: true
  411. email:
  412. state:
  413. attributes_cache: {}
  414.  
  415. changed_attributes:
  416. admin: false
  417. id:
  418. new_record: true
  419. flash: !map:ActionController::Flash::FlashHash {}
  420.  
  421.  
  422. Response
  423.  
  424. Headers:
  425.  
  426. {"cookie"=>[],
  427. "Cache-Control"=>"no-cache"}
Add Comment
Please, Sign In to add comment