Forum: Ruby on Rails Connecting/Merging 2 different inputs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Db11dd5d32de4e463a19d905d81e4ff2?d=identicon&s=25 mayukarunasekara@gmail.com (Guest)
on 2009-01-18 11:10
(Received via mailing list)
Hi

I have a form which contain a student names and their attendance.
For each student name there is a text box to input attendance.I want
to create a connection between the 'name' and it's attendance. I think
I should merge the student name and the attendance.But could not
achieve it as yet.

Can nyone give me an idea how to do this.

Thanks
Viper
Dd9ab512706dd6cb1de818a658566ba2?d=identicon&s=25 nas (Guest)
on 2009-01-19 14:54
(Received via mailing list)
how about this

def name_with_attendence
      [name, attendence].join(' ')
end

def name_with_attendence=(name_attendence)
    if name_attendence
       split_name_and_attendence = name_attendence.split(' ')
       self.name = split_name_and_attendence.first
       self.attendence = split_name_and_attendence.last
    else
      'name and attendece not valid'
    end
end

above i am only checking the presence of name_attendence but not its
format or any other stuff that you might have to add in your model or
code

On Jan 18, 10:09 am, "mayukarunasek...@gmail.com"
This topic is locked and can not be replied to.