lundi 24 juin 2019

how to build a tick box with rails on view/index

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, can you help?

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>


(i know to mark as valid should use link to but i am not too sure where to link to)

 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

(I've also created the validated as boolean in the db)

this is the controller:

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

Aucun commentaire:

Enregistrer un commentaire