Friday 15 June 2012

ruby on rails - Remove entry from a table without deleting it from a database -


I created a small web app in which the main view shows a table and the administrator has the option of deleting a line This is by using the database:

  *. Delete   

Although I want to put all the entries in the database but still would like the option for the user to be able to remove the rows from the table and to ensure that I was thinking about using two separate database tables, but did they want to see if there is any easy way?

Here's my main view:

  & lt; H1 & gt; Student list & lt; / H1> & Lt; Table class = "tables" & gt; & Lt; TR & gt; & Lt; Th & gt; First name & lt; / Th & gt; & Lt; Th & gt; Last name & lt; / Th & gt; & Lt; Th & gt; Date submitted & lt; / Th & gt; & Lt; Th & gt; Bottom priority & lt; / Th & gt; & Lt; Th & gt; & Lt; / Th & gt; & Lt; / TR & gt; & Lt;% @ students.each do | Student |% & gt; & Lt; TR & gt; & Lt; Td> & Lt;% = student.f_name% & gt; & Lt; / Td> & Lt; Td> & Lt;% = student.l_name% & gt; & Lt; / Td> & Lt; Td> & Lt;% = student.created_at% & gt; & Lt; / Td> & Lt; Td> & Lt;% = student.floor_pref% & gt; & Lt; / Td> & Lt; Td> & Lt;% = button_to 'Remove', student, method :: delete, data: {confirm: 'are you sure?' }% & Gt; & Lt; / Td> & Lt; / TR & gt; & Lt;% end% & gt; & Lt; / Table & gt; & Lt; Br / & gt; & Lt;% = link_to 'New Student', new_student_path% & gt; You can easily do this by creating an extra column in the same table with boolean value.    

Therefore the name of the additional column may be disabled. The removed row will have activation of 0 and the remainder will be 1. And when you bring data, then where is the extra check active = 1

No comments:

Post a Comment