My app has a timesheet, which is a collection of many TimeCards, based on a Date. I have one user that can create new TimeCards just fine, except on three associated Jobs. Each time he saves he gets a 500 error. Looking at the params, they come across jumbled and my processing method chokes: (The first "time_cards" entry is correct, the second is split by the third) Parameters: { "date"=>"2008-12-17", "time_cards"=>[ { "job_id"=>"3107", "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17", "id"=>"285875", "note"=>"Akron e-rate cable project counts/ FSR presentation", "hours"=>"2", "user_id"=>"178" }, { "time_card_date"=>"2008-12-17", "id"=>"285774", "user_id"=>"178" }, { "job_id"=>"3089", "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17", "id"=>"", "note"=>"progress drawing and spec revision", "hours"=>"2.5", "user_id"=>"178" }, { "job_id"=>"3107", "time_card_entry_type"=>"Field", "note"=>"Akron e-rate cable project counts", "hours"=>"2" } ] } The form is a partial that uses index => nil, and it works for all other users, except this guy, on these associated Jobs. %tr.entry - fields_for "time_cards[]", entry, :index => nil do |entry_form| = entry_form.hidden_field(:time_card_date, :value => @date) = entry_form.hidden_field(:user_id, :value => session [:timesheet_user].id) = entry_form.hidden_field(:id) %td= entry_form.select :job_id, available_jobs %td= entry_form.select :time_card_entry_type, allowable_types %td= entry_form.text_field :hours, :size => 5 %td= entry_form.text_field :note I''ve scratched my head on this one for weeks, anything look out of order? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
did you check if it is rendered correctly? whats your html output for that code? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 29, 9:50 am, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> did you check if it is rendered correctly? whats your html output for > that code?Yep, it renders correctly (below); as noted, it works for all but one user... <tr class=''entry''> <input id="time_cards__time_card_date" name="time_cards[] [time_card_date]" type="hidden" value="2008-12-28" /> <input id="time_cards__user_id" name="time_cards[][user_id]" type="hidden" value="121" /> <input id="time_cards__id" name="time_cards[][id]" type="hidden" /> <td> <select id="time_cards__job_id" name="time_cards[] [job_id]"><option value="3375">J080183 - Dynamix Office 855 Grandview</ option> <option value="3373">J080181 - CCC Westlake Phase 1 Building</ option> ... </td> <td> <select id="time_cards__time_card_entry_type" name="time_cards[] [time_card_entry_type]"><option value="Bereavement">Bereavement</ option> <option value="Vacation">Vacation</option></select> ... </td> <td><input id="time_cards__hours" name="time_cards[][hours]" size="5" type="text" /></td> <td><input id="time_cards__note" name="time_cards[][note]" size="30" type="text" /></td> </tr> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
as rendering the view seems ok, i suppose it has something to do with the logic behind it. <stating the obvious> so far your posted params show, that your controller receives the second entry as first parameter, the first entry gets split by the third, which is not yet saved or the id got lost. additionally: all this only happens for one user. </stating the obvious> honestly: this seems strange. some points to start looking for an answer: - are you able to reproduce the error, if you login as that user? - what about that user? does he have any ''special qualities'' (like: has special rights or uses lynx to access the site *g*)? - does your session variable contain the correct data? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> honestly: this seems strange. some points to start looking for an > answer: > - are you able to reproduce the error, if you login as that user? > - what about that user? does he have any ''special qualities'' (like: > has special rights or uses lynx to access the site *g*)? > - does your session variable contain the correct data?It sure does ;) - If I login as the user, I can''t seem to reproduce the error, but this happens constantly for this one guy, on these three Jobs. Ugh. - The user is just a standard User, no awesome Admin qualities, and he uses IE7 against my better judgment - The session[:timesheet_user].id is correct (and correctly set in the params hash) - A TimeCard with a blank ID means that it is new (and not yet saved). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> - If I login as the user, I can''t seem to reproduce the error, but > this happens constantly for this one guy, on these three Jobs. Ugh.this sucks. but i think as long as you can''t reproduce the error, you porbably won''t be able to fix it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 29, 10:41 am, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > - If I login as the user, I can''t seem to reproduce the error, but > > this happens constantly for this one guy, on these three Jobs. Ugh. > > this sucks. but i think as long as you can''t reproduce the error, you > porbably won''t be able to fix it.I can''t reproduce it, but I can see the effect. Everything seems to be in place and the snag is that the params is jumbled. I''m not doing anything against Rails'' opinion ;( hrm. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Anyone else by chance? It really seems like this is a lower level error... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt Darby wrote:> <tr class=''entry''> > <input id="time_cards__time_card_date" name="time_cards[] > [time_card_date]" type="hidden" value="2008-12-28" /> > <input id="time_cards__user_id" name="time_cards[][user_id]" > type="hidden" value="121" /> > <input id="time_cards__id" name="time_cards[][id]" type="hidden" /> > > <td>Those first three fields are not enclosed in a cell. That may cause IE to send the parameters in the wrong order. Please log and post the raw_post string. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Those first three fields are not enclosed in a cell. > That may cause IE to send the parameters in the wrong order. > > Please log and post the raw_post string.Ahh, IE, my old friend. Perhaps this is why I wasn''t able to recreate it. Here is the raw POST: Processing TimeCardsController#day (for 192.168.1.192 at 2008-12-18 09:14:13) [POST] Parameters: {"date"=>"2008-12-17", "time_cards"=>[{"job_id"=>"3107", "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17", "id"=>"285875", "note"=>"Akron e-rate cable project counts/ FSR presentation", "hours"=>"2", "user_id"=>"178"}, {"time_card_date"=>"2008-12-17", "id"=>"285774", "user_id"=>"178"}, {"job_id"=>"3089", "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17", "id"=>"", "note"=>"progress drawing and spec revision", "hours"=>"2.5", "user_id"=>"178"}, {"job_id"=>"3107", "time_card_entry_type"=>"Field", "note"=>"Akron e- rate cable project counts", "hours"=>"2"}]} --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt Darby wrote:>> Those first three fields are not enclosed in a cell. >> That may cause IE to send the parameters in the wrong order. >> >> Please log and post the raw_post string. > > Ahh, IE, my old friend. Perhaps this is why I wasn''t able to recreate > it.Well, I can''t blame IE for tripping up on invalid HTML.> Here is the raw POST: > > Processing TimeCardsController#day (for 192.168.1.192 at 2008-12-18 > 09:14:13) [POST] > Parameters: {"date"=>"2008-12-17", "time_cards"=>[{"job_id"=>"3107", > "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17",What you really need to look at is not the params hash, but the string posted by the browser. See this by adding "logger.info request.raw_post" to your controller action. If the parameters are indeed posted out of order, then the problem was with the missing td tags. However a correct order would instead suggest a bug in Rails'' parameter processing. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for your help, it seems to have been having the hidden elements outside a <td>. I wouldn''t think that having hidden elements outside a cell (but still in the form) would be invalid, but then again, I didn''t explicitly validate. Thanks for your help ;) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---