Created
April 19, 2011 08:59
-
-
Save kracekumar/927036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#controller | |
def add_new_chapter | |
@chapter=Chapter.new | |
@user=current_user | |
@subjects=[] | |
@subject_final=[[]] | |
count=0 | |
if @user.admin? | |
@subjects=Subject.all(:select=>'id,name,batch_id') | |
puts "#{@subjects}" | |
@subjects.each do |t| | |
@subjects_all=Batch.find(t.batch_id,:select=>'name') | |
@subject_final[count]['id']=t.id.to_i | |
@subject_final[count]['name']="#{@subject_all.name} #{t.name}" | |
count+=1 | |
end | |
elsif @user.employee | |
@employee=Employee.find_by_employee_number(@user.username) | |
@subjects=EmployeesSubject.find_by_employee_id(@employee.id,:select=>'subject_id') | |
@subjects.each do |t| | |
@subjects_all=Batch.find(t.subject_id,:select=>'name') | |
@subject_final[count]['id']=t.id.to_i | |
@subject_final[count]['name']="#{@subject_all.name} #{t.name}" | |
count+=1 | |
end | |
else | |
end | |
respond_to do |format| | |
format.js { render :action =>'new_chapter' } | |
end | |
#error | |
Batch Columns (0.6ms) SHOW FIELDS FROM `batches` | |
Batch Load (0.1ms) SELECT name FROM `batches` WHERE (`batches`.`id` = 2) | |
TypeError (can't convert String into Integer): | |
app/controllers/online_exam_controller.rb:57:in `[]=' | |
app/controllers/online_exam_controller.rb:57:in `add_new_chapter' | |
app/controllers/online_exam_controller.rb:55:in `each' | |
app/controllers/online_exam_controller.rb:55:in `add_new_chapter' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment