Apuntes Rails

Apuntes de Ruby on Rails, programación en GNU/Linux y Mac

Creando un filtro fecha

TAGS: None

Aunque parezca una tontería pero siempre es util tener un partial con un selector de fecha.

Creamos un parcial por ejemplo _date_select.erb

  1. <%
  2. name = "date" if name.nil?
  3. %>
  4.      <%=select_day(1,:prefix=>name)%>/
  5.      <%=select_month(Date.today,
  6. :use_month_names =>  %w( Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre  Diciembre),:prefix=>name)%>/
  7.      <%= select_year(Date.today, :start_year => Communicationsview.first_year, :end_year =>Communicationsview.last_year,:prefix=>name) %>
  8.  

Ahora solo falta llamar desde una vista usando

  1. <%=render :partial=>"/fijos/date_filter" , :locals=>{:name =>"filtro[fecha]"} %>
  2.  

Fácil, verdad?

TAGS: None

Leave a Reply

© 2009 Apuntes Rails. All Rights Reserved.

This blog is powered by Wordpress and the Magatheme Wordpress Theme by Mid MO SEO.