I am trying to build a tick box section with rails on view/index, these are all the steps I’ve taken so far I know that I need to do something about routes.rb, thank you!!
(so the scootiescoupon is validated it will be ticked or mark as validated and being highlighted)
this is the view:
<table class="table table-hover">
<thead>
<tr>
<th>Coupon</th>
<th>first_name</th>
<th>surname</th>
<th>email</th>
<th>occupation</th>
<th>validation</th>
</tr>
</thead>
<tbody>
<% @scooties_coupons.each do |scooties_coupon| %>
<tr>
<td><%= scooties_coupon.coupon %></td>
<td><%= scooties_coupon.first_name %></td>
<td><%= scooties_coupon.surname %></td>
<td><%= scooties_coupon.email %></td>
<td><%= scooties_coupon.occupation %></td>
<td><%= link_to "Mark as Valid", method: :patch %></td>
</tr>
<% end %>
</tbody>
</table>
create_table "scooties_coupons", force: :cascade do |t|
t.string "coupon"
t.boolean "redeemed", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "email"
t.integer "expires_in"
t.string "first_name"
t.string "surname"
t.string "oppcupation"
t.string "occupation"
t.boolean "validated"
t.index ["coupon"], name: "index_scooties_coupons_on_coupon"
end
def update
@scooties_coupon = ScootiesCoupon.find(scooties_coupon_params)
@scooties_coupon.update( scooties_coupon_params
redirect_to scooties_coupons_new_path
end
def scooties_coupon_params
params.require(:scooties_coupon).permit(:first_name, :surname, :email, :occupation)
end