ruby on rails - Model not storing values -


through references storing values many-to-many relationship in participantattendance,teamattendance table. table has references of participant table , event table.

i using index page of participantattendance , teamattendance store values.

routes file:

rails.application.routes.draw  resources :team_results    collection     put :result    end  end resources :participant_results   collection    put :result   end end resources :team_attendances   collection    put :attendance   end end  resources :participant_attendances   collection       put :attendance   end end resources :groupinfos resources :events resources :participants 'results/index' 'attendance/index' root "participants#index" end 

before setting relationship between participants_result,team_results , participant,event. attendance module storing values automatically, not storing values supposed do.

event.rb :

class event < activerecord::base  has_many :selections has_many :participants, through: :selections  has_many :groupevents has_many :groupinfos, through: :groupevents  has_many :participant_attendances has_many :participants, through: :participant_attendances  has_many :participant_results has_many :participants, through: :participant_results  has_many :team_attendances has_many :groupinfos, through: :team_attendances  has_many :team_results has_many :groupinfos, through: :team_results  validates :name, presence: true end 

participant.rb:

class participant < activerecord::base  has_many :selections has_many :events, through: :selections  has_many :groupdetails has_many :groupinfos, through: :groupdetails  has_many :participant_attendances has_many :events, through: :participant_attendances  has_many :participant_results has_many :events, through: :participant_results   validates :name, presence: true validates :email,:email => true validates :phone,presence: true,                  numericality: true,                  length: { :minimum => 10, :maximum => 10 } validates :college, presence: true  def full_info     "#{name}, participant id: #{id} " end end 

participant_attendance.rb :

class participantattendance < activerecord::base  belongs_to :participant  belongs_to :event end 

participant_attendances/index.html.erb :

<p id="notice"><%= notice %></p> <h1>listing participant attendances</h1> <%= form_tag attendance_participant_attendances_path, method: :put %> round 1 <%= radio_button_tag "round", 1 %>| round 2 <%= radio_button_tag "round", 2 %>|  round 3 <%= radio_button_tag "round", 3 %>| round 4 <%= radio_button_tag "round", 4 %>| round 5 <%= radio_button_tag "round", 5 %><br><br> present :  <%= radio_button_tag "mark_present", "present" %>| absent  : <%= radio_button_tag "mark_present", "absent" %><br><br> <%= submit_tag "mark attendance" %>   <table> <thead> <tr>   <th></th>   <th>participant</th>   <th>events</th>   <th>round</th>   <th>status</th>    <th colspan="5"></th> </tr> </thead> <tbody> <% @participant_attendances.each |participant_attendance| %>   <tr>     <td><%= check_box_tag "p_ids[]", participant_attendance.id %></td>           <td><%= participant_attendance.participant.name %></td>     <td><%= participant_attendance.event.name %></td>     <td><%= participant_attendance.round %></td>     <td><%= participant_attendance.status %></td>       <td><%= link_to 'show', participant_attendance %></td>     <td><%= link_to 'edit', edit_participant_attendance_path(participant_attendance) %></td>     <td><%= link_to 'destroy', participant_attendance, method: :delete, data: { confirm: 'are sure?' } %></td>   </tr> <% end %> </tbody> </table> <% end %> 

participantattendancescontroller file method:

def attendance params[:p_ids] if params[:mark_present]=="present"   participantattendance.where(id: params[:p_ids]).update_all(status: 'present', round: params[:round]) else   participantattendance.where(id: params[:p_ids]).update_all(status: 'absent', round: params[:round]) end    redirect_to participant_attendances_url end 

what problem ?


Comments