Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Customizando o select do Tora
<%
tipo_ocor = {
:association => f.object.class.reflect_on_association(:tipo_ocorrencia),
:options => {:include_blank => true},
:html_options => {
:onchange => remote_function(:url => {
:controller => "advocacia/processos",
:action => "campos_tipo_ocorrencia",
:index => index
},
:with => "'id=' + escape($('processo_ocorrencias_#{index}_tipo_ocorrencia_id').value)" )}
}
%>
<%= f.select(tipo_ocor[:association].primary_key_name,
TipoOcorrencia.find(:all, :conditions => "ativo is true or ((ativo is false or ativo is null) and id='#{f.object.try(:tipo_ocorrencia_id)}')").collect {|p| [ p.send('tipo'), p.id ] },
tipo_ocor[:options],
tipo_ocor[:html_options])
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment