Hello. I'm using activescaffold-3.4.29, rails 4.2.0 and ruby 2.2.0.

I have some time type fields, and made some form overrides on them. Here is
an example:

 app/views/work_hours_configs/_visit_time_min_form_column.html.erb

dl><dt><label for="record_visit_time_min">Tempo de visita:</label></dt>
<dd> Entre <%=select_time(record.visit_time_min, :include_blank => true,
:prefix => :visit_time_min)%> e </b><%=select_time(record.visit_time_max,
:include_blank => true, :prefix => :visit_time_max)%></dd></dl>


On this override, I actually use some time selectors to represent some hour
ranges, like this:

http://postimg.org/image/7ddrlu4lz/

And I set all the parameters to the appropriate table columns in
before_create_save and before_update_save in works_configs_controller.rb


  def before_update_save(record)
    #raise params.to_json
    before_create_save(record)
  end

  def before_create_save(record)
    record.visit_time_min =
"#{params[:visit_time_min][:hour]}:#{params[:visit_time_min][:minute]}" if
params[:visit_time_min]
    record.visit_time_max =
"#{params[:visit_time_max][:hour]}:#{params[:visit_time_max][:minute]}" if
params[:visit_time_max]
    record.started_at_min =
"#{params[:started_at_min][:hour]}:#{params[:started_at_min][:minute]}" if
params[:started_at_min]
    record.started_at_max =
"#{params[:started_at_max][:hour]}:#{params[:started_at_max][:minute]}" if
params[:started_at_max]
    record.ended_at_min =
"#{params[:ended_at_min][:hour]}:#{params[:ended_at_min][:minute]}" if
params[:ended_at_min]
    record.ended_at_max =
"#{params[:ended_at_max][:hour]}:#{params[:ended_at_max][:minute]}" if
params[:ended_at_max]
    record.duration_min =
"#{params[:duration_min][:hour]}:#{params[:duration_min][:minute]}" if
params[:duration_min]
    record.duration_max =
"#{params[:duration_max][:hour]}:#{params[:duration_max][:minute]}" if
params[:duration_max]
  end


Everything works as expected, when creating. When updating, the first time
I edit a record, it also works, but every subsequent time after the first,
it doesn't. The only way to edit again is to refresh the whole page. Any
thoughts? Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.

Reply via email to