Skip to content

Instantly share code, notes, and snippets.

@vluzrmos
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vluzrmos/18ad0329cf54a3a361a2 to your computer and use it in GitHub Desktop.
Save vluzrmos/18ad0329cf54a3a361a2 to your computer and use it in GitHub Desktop.
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