Greetings, I'm trying to create a spreadsheet using ekuseru.
I have a form that a user enters a course number in and submits. Like 'HA2211'. The action in my controller this goes to is course_enrollment. The view is course_enrollment.xls.eku.
My controller: (in part) class Sso::ReportsController < ApplicationController respond_to :html, :xls
def course_enrollment # create vars long_nbr, short_nbr, ten_semesters_ago from paras[:course] sent from form long_nbr = params[:course].slice(2,4) short_nbr = params[:course].slice(3,3) ten_semesters_ago = '' if CourseTaken.last_semester == 20 ten_semesters_ago = (Time.now.year-5).to_s + '20' else ten_semesters_ago = (Time.now.year-6).to_s + '70' end @students = CourseTaken.students_enrolled_in_course(long_nbr, short_nbr, ten_semesters_ago) if !@students.nil? respond_with @students, :format => :xls end end
The error I get is: undefined method `model_name' for ActiveRecord::Relation:Class app/controllers/sso/reports_controller.rb:33:in `course_enrollment'
Line 33 in my controller is:
respond_with @students, :format => :xls
I have a correctly named view: course_enrollment.xls.eku
I've tested and verified via my console the line:
@students = CourseTaken.students_enrolled_in_course(long_nbr, short_nbr,
ten_semesters_ago) This works and @students is not nill.
I do pretty much the same thing in another action for another spreadsheet report and it works fine. I've searched and googled but cannot find what my problem might be.
Thoughts? Thanks for any tips or pointers. JohnC