i have a verified and unverified states in my booking model, how do i implement helper methods for my views? i would like something like this in my index views.
<% @bookings.each do |booking| %>
<%= link_to booking_path(booking) do %>
<%= booking.name %>
<% if verified_booking %>/* here is where i want implemented*/
<div class="pt-4 font-semibold"><i class="fa fa-user-check"></i></div>
<% end %
<% end %>
</div>
<% end %>
helper method
def verified_booking
!!Booking.verified
end
booking model
include AASM
aasm :column => :state, :whiny_transitions => false do
state :unverified, initial: true
state :verified
event :verify do
transitions from: [:unverified], to: :verified
end
end
ApplicationHelper.rb
def verified_booking(state)
# check state in the database if it is verified
# return true if state is verified
# return false if not verified
end
html.erb
<% @bookings.each do |booking| %>
<%= link_to booking_path(booking) do %>
<%= booking.name %>
<% if verified_booking(booking.state) %>/* here is where i want implemented*/
<div class="pt-4 font-semibold"><i class="fa fa-user-check"></i></div>
<% end %
<% end %>
</div>
<% end %>