Let's say I have a column of remote staff and each of those staff can either be home worker or remote worker.
From the remote staff index page, I can click on create home worker and it will take me to the new home worker create page.
The following builds me a link that takes me to the create home worker page..
column :home_worker do |remote_staff|
if remote_staff.home_worker
link_to("Home worker ##{remote_staff.home_worker.id}", admin_home_worker_path(remote_staff.home_worker), method: :get)
else
link_to('Create Home Worker', redirect_to_home_worker_create_admin_remote_staff_path(remote_staff), method: :get)
end
end
Let's say all remote staff also have full names and so do home workers How do I pre-fill the create home worker full name column?
I found a way to do it... I just needed to put the following into the new home worker f.inputs and then pass that value as full_name
remote_staff_full_name = RemoteStaff.find(params['home_worker']["remote_staff_id"]).full_name unless params['home_worker'].nil?
f.input :full_name, label: "Full name", :input_html => { :value => remote_staff_full_name }