I think issue may be not to set params under :record. Try to use 
params[:record][:visit_time_min] and so on.

El Jueves, 22 de octubre de 2015 20:29:56 Cláudio Forain escribió:
> Sure, here is the record values when it works:
> 
> {"id":12,"color":"4B0DA8","visits_min":null,"visits_max":null,"clients_min":
> null,"clients_max":null,"visit_time_min":"2000-01-01T00:01:00.000Z","visit_t
> ime_max":"2000-01-01T02:04:00.000Z","duration_min":"2000-01-01T13:14:00.000Z
> ","duration_max":"2000-01-01T15:16:00.000Z","active":false,"started_at_min":
> "2000-01-01T05:06:00.000Z","started_at_max":"2000-01-01T07:08:00.000Z","ende
> d_at_min":"2000-01-01T09:10:00.000Z","ended_at_max":"2000-01-01T11:12:00.000
> Z"}
> 
> Then I added +1 on each field editing again without reloading the page
> (only hour and minute matter):
> 
> {"id":12,"color":"4B0DA8","visits_min":null,"visits_max":null,"clients_min":
> null,"clients_max":null,"visit_time_min":"2000-01-01T00:01:00.000Z","visit_t
> ime_max":"2000-01-01T02:04:00.000Z","duration_min":"2000-01-01T13:14:00.000Z
> ","duration_max":"2000-01-01T15:16:00.000Z","active":false,"started_at_min":
> "2000-01-01T05:06:00.000Z","started_at_max":"2000-01-01T07:08:00.000Z","ende
> d_at_min":"2000-01-01T09:10:00.000Z","ended_at_max":"2000-01-01T11:12:00.000
> Z"}
> 
> Still no change, but if I check the params before setting them to the
> record:
> 
> 
> {"utf8":"â","_method":"put","record":{"color":"4B0DA8","active":"0","visits_
> min":"","visits_max":"","clients_min":"","clients_max":""},"visit_time_min":
> {"day":"1","hour":"00","minute":"01","month":"1","year":"1"},"visit_time_max
> ":{"day":"1","hour":"02","minute":"04","month":"1","year":"1"},"started_at_m
> in":{"day":"1","hour":"05","minute":"06","month":"1","year":"2000"},"started
> _at_max":{"day":"1","hour":"07","minute":"08","month":"1","year":"2000"},"en
> ded_at_min":{"day":"1","hour":"09","minute":"10","month":"1","year":"1"},"en
> ded_at_max":{"day":"1","hour":"11","minute":"12","month":"1","year":"1"},"du
> ration_min":{"day":"1","hour":"13","minute":"14","month":"1","year":"2000"},
> "duration_max":{"day":"1","hour":"15","minute":"16","month":"1","year":"2000
> "},"commit":"Atualizar","eid":"0f726c1c7c83871405ff3781a71db031","controller
> ":"work_hours_configs","action":"update","id":"12"}
> 
> 
> It seems that the params are getting ignored the second time arround. If
> you like, I could provide a demo app just to reproduce this problem. Thanks
> in advance.
> 
> On Thu, Oct 22, 2015 at 5:58 AM, Sergio Cambra <[email protected]>
> 
> wrote:
> > Can you debug if record has right values after before_update_save?
> > 
> > El Miércoles, 21 de octubre de 2015 19:39:22 Cláudio Forain escribió:
> > > 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