Prev | Current Page 333 | Next

David Berube

"Practical Reporting with Ruby and Rails"

post?
count = 0
training_class = TrainingClass.find_by_id(params[:training_class_id])
training_class_date = Date.parse(params[:training_class_date])
params[:trainee].each do |index, t|
next if t[:name]==''
student = Student.find_or_create_by_name_and_employer( t[:name],
t[:employer])
student.grades.create(:percentage_grade => t[:grade],
:training_class=>training_class,
:took_class_at=>training_class_date)
count = count +1
end
flash[:notice]="#{count} Entries Uploaded!"
end
end
def index
@grades = Grade.find(:all)
render(:layout=>false)
end
end
Save this file as app/controllers/log_controller.rb.
Now create the views for the log controller??™s actions. The first view lets the students
enter data, as shown in Listing 12-5.
CHAPTER 12 n CREATING REPORTS WITH RUBY AND MICROSOFT OFFICE 239
Listing 12-5. Log Uploader View (app/views/log/upload.html.erb)
<%@title='Upload Training Log'
number_of_elements_displayed = 10
%>
<% form_tag do %>

Class: <%=select ('training_class_id', nil,
TrainingClass.


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

aurora amefa tanie noclegi w polsce producent sal zabaw Władysławowo wakacje skarpetki narciarskie męskie