hey i have project_site model where user uploads name file into database. and another model i have is project_manager which has accept and reject Boolean field and remark field along with each project_site entries. but i am unable to set remark and status boolean data into project_manager database. here is my code- project_manager.rb
class ProjectManager < ApplicationRecord
belongs_to :project_site
end
project_site.rb
class ProjectSite < ApplicationRecord
has_many :project_managers, dependent: :destroy
validates :name,:attendance, presence: true
end
project_manager_dashboard
<table>
<thead>
<tr>
<th>Uploaded By</th>
<th>Attendance File</th>
<th colspan="2"></th>
</tr>
</thead>
<tbody>
<% @project_sites.each do |project_site| %>
<tr>
<td><%= project_site.name.titleize %></td>
<% if project_site.attendance? %>
<td><%= link_to "View Attendance", project_site.attendance.url, :class => "fi-page-export-csv" %></td>
<% else %>
<td>No File Present</td>
<% end %>
<td>
<%= form_for [ @project_site, @project_manager ] do |f| %>
<div class="row">
<div class="medium-6 columns">
<%= f.radio_button :status, true %>
<%= f.label :approve %>
<%= f.radio_button :status, false %>
<%= f.label :reject %>
</div>
<br>
<br>
<div class="medium-6 cloumns">
<%= f.label :remark %><br/>
<%= f.text_area :remark %>
</div>
</div>
<div>
<%= f.submit 'Submit', :class => 'button primary' %>
</div>
<% end %>
</td>
<td><%= link_to 'Action', project_site, :class=>'button tiny primary' %></td>
</tr>
<% end %>
</tbody>
</table>
project_manager_controller.rb
class ProjectManagersController < ApplicationController
def index
@project_sites = ProjectSite.all.order("created_at DESC").paginate(page: params[:page], per_page: 10)
@project_manager = ProjectManager.new
#@project_manager.project_site_id = @project_site.id
end
def create
@project_manager = ProjectManager.new(remark_params)
@project_manager.project_site_id = params[:project_site_id]
@project_manager.save
redirect_to project_managers_path
end
def remark_params
params.require(:project_manager).permit(:remark, :status)
end
end
routes.rb
resources :project_sites
resources :project_managers
Aucun commentaire:
Enregistrer un commentaire