ruby on rails - Edit multiple saved records -


I'm trying to develop a simple practice log app, and I'm stuck (again). A user selects a category and a specific workout, and I return a list of exercises related to that exercise.

An attempt is a user-specific example of a practice.

  Class Exercises & lt; ActiveRecord :: Base has has_many: endeavor end-of-end efforts & lt; ActiveRecord :: Base is_to: Expiration Expiration  

I am retrieving the list of exercises in the Attempt Administrator

  Class Attempts Controller & lt; ApplicationController def log_workout @exercises = Exercise.where ("category_id =? And workout_id =?", Parameter [: exercise] [: category_id], param [: exercise] [: workout_id]) @Effort = try.new end end  

The user logs his work using the following tasks

  <% = form_tag save_workout_path, method :: put do%> & Lt; Table & gt; & Lt; TR & gt; & Lt; Th & gt; Exercise & lt; / Th & gt; & Lt; Th & gt; Set & lt; / Th & gt; & Lt; Th & gt; Representative & lt; / Th & gt; & Lt; / TR & gt; Do & lt;% @ exercises.each Exercise | & Gt%; & Lt;% = fields_for "attempt []", @Effort do | F | & Gt%; & Lt; TR & gt; & Lt; Td> & Lt;% = exercise.name% & gt; & Lt; / Td> & Lt; Td> & Lt;% = f.number_field: set% & gt; & Lt; / Td> & Lt; Td> & Lt;% = f.number_field: reps% & gt; & Lt; / Td> & Lt;% = f.hidden_field: exercise_id ,: value = & gt; Exercise.id% & gt; & Lt; / TR & gt; & Lt;% end% & gt; & Lt;% end% & gt; & Lt; / Table & gt; & Lt;% = submit_tag "Login it"% " & Lt;% end% & gt; Classroom Access Controller & lt; ApplicationController def params [: attempts] .each do | Values ​​| If current_user.efforts.create (value) Flash [: notice] = 'Attempts saved successfully.' And take action again: 'new' end end end end  

I'm not sure how this is right, but it works. My problem is now trying to retrieve the saved efforts and is allowing them to modify in a single form. (Please allow the user to edit their workout logs) any guidance / support


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -