Prev | Current Page 332 | Next

David Berube

"Practical Reporting with Ruby and Rails"

rb. This controller has just a
single view, shown in Listing 12-3.
Listing 12-3. Homepage Index View (app/views/homepage/index.html.erb)

Training Log Application


Actions:


  • <%=link_to 'Upload Log', :action=>:upload, :controller=>:log %>
  • <%=link_to 'Download XML', :action=>:index, :controller=>:log %>

Save this code as app/views/homepage/index.html.erb.
Next, create the log controller, which will keep a log of all of the students??™ grades:
ruby script/generate controller log
exists app/controllers/
exists app/helpers/
CHAPTER 12 n CREATING REPORTS WITH RUBY AND MICROSOFT OFFICE 238
create app/views/uploader
exists test/functional/
create app/controllers/log_controller.rb
create test/functional/log_controller_test.rb
create app/helpers/log_helper.rb
This controller will have an upload action to add new data and a view action to view
the old data. Listing 12-4 shows the code.
Listing 12-4. Log Controller (app/controllers/log_controller.rb)
class LogController < ApplicationController
def upload
if request.


Pages:
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344