hi there, i''m very new in ruby. i need to solve this asap.
im out of idea already.
please help me. thank u.
[code=]def egradebook
end
def monthlytest #will find all record of person wif id of the current
user (teacher) login
@teachersubjects = Teachersubject.find(:all, :conditions => ["user_id
?", session[:user_id]])
end
def monthlytestadd #here will list all student in class which has
teacher of id 1001
@hello = Teachersubject.find(params[:id])
@students = Student.find(:all, :conditions => ["class1_id = ?",
@hello.class1_id])
end
def addmark #Problem. now, the params[:id] has become class_id, so i
cant take the teacher data (subject, year, semester) to be save in new
gradebook record
@teachersubject = Teachersubject.find(params[:id])
@students = Student.find(:all)
@gradebook = Gradebook.new(params[:gradebook])
@gradebook.user_id = session[:user_id]
@gradebook.subject_id = @teachersubject.subject_id #this part got prob
@gradebook.year = @teachersubject.year #this part got prob
@gradebook.semester = teachersubject.semester #this part got prob
@gradebook.class1_id = params[:id] #and maybe need to change this part
also?
@gradebook.monthly = "yes"
if @gradebook.save
flash[:notice] = ''Student Mark Successfully Added.''
redirect_to :action => ''monthlytest''
else
flash[:notice] = ''Error, Please Login''
render :action => ''login''
end
end[/code]
i tried something like this which i think it could find the teacher''s
subject already but it turned error.
[code=]def addmark
params[''id''] = session[:user_id]
@students = Student.find(:all)
@teachersubject = Teachersubject.find(params[:id])
@gradebook = Gradebook.new(params[:gradebook])
@gradebook.user_id = session[:user_id]
@gradebook.subject_id = @teachersubject.subject.id
@gradebook.year = @teachersubject.year
@gradebook.semester = @teachersubject.semester
@gradebook.class1_id = @teachersubject.class1_id
@gradebook.monthly = "yes"
if @gradebook.save
flash[:notice] = ''Student Mark Successfully Added.''
redirect_to :action => ''monthlytest''
else
flash[:notice] = ''Error, Please Login''
render :action => ''login''
end
end[/code]
here''s the error :
ActiveRecord::RecordNotFound in AdminController#addmark
Couldn''t find Teachersubject with ID=1003
i want to get teacher''s data from table teachersubject which consist of
user_id, subject_id, class1_id, semester, year.
but i dunno how to get those. maybe my params is wrong. 1003 is the
teacher user_id
here are the data in the teachersubject table
id -- subject_id -- user_id -- class1_id -- year -- semester
1 ----- 2 --------- 1003 --------- 1 ------ 2008 ----- 1
2 ----- 3 --------- 1003 --------- 2 ------ 2008 ----- 1
please give some ideas for me to solve this asap, thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---