同名学生加身份证后4位辨别

<%= f.label :选择学生 %>:
<%=f.select( :intern_id, Intern.find(:all, :conditions=>" status != '离职' ", :conditions=>"des_intern is null",:order=>"convert(name using gbk)").collect {|p| [ p.same, p.id ] },:include_blank => true)%>


  def same
    namer = self.name
    full_name=Intern.find_by_sql("select * from interns where name='#{namer}' and status != '离职' and des_intern is null")
    i=0
    for name in full_name
      i=i+1
    end
    if i==1
      namer = self.name
    else
      namer = self.name+" "+self.dnum.last(4)
    end
    return namer

    end

你可能感兴趣的:(同名辨别)