jeudi 26 décembre 2019

not able to print date in Month_name-yyyy format in rails

hi i am taking date input in mm-yyyy format i want to print date in formate of month_name-yyyy format. i have used strftime but i am not to able print the date as my required format. index.html.erb code

          <td><%= project_site.name.titleize %></td>
          <td><%= project_site.created_at.strftime('%b-%Y') %></td>
          <td><%= link_to ' View attendance', project_site.file, :class => "fi-page-export-csv" %></td>
          <% project_site.manager_remarks.each do |manager_remark| %>
            <% if manager_remark.decision == false %>
              <td><%= 'Rejected' %></td>
            <% elsif manager_remark.decision == true %>
              <td><%= "Approved" %></td>
            <% else %>
              <td><%= "Pending" %>
            <% end %>
         <% end %>
         <td><%= project_site.attendance_month.strftime('%b %Y') %></td>
          <td><%= link_to 'Remark ', project_site %><span>(<%= project_site.manager_remarks.size %>)</span></td>
          <td><%= link_to 'Edit', edit_project_site_path(project_site) %></td>
          <td><%= link_to 'Delete', project_site, method: :delete, data: { confirm: 'Are you sure?' } %></td>
        </tr>

form.html.erb code

        <%= form.label :name %>
        <%= form.text_field :name %>
      </div>
  <!--
      <div class="field medium-3 columns">
        <%= form.label :date %>
        <%= form.text_field :date, class: 'datepicker' %>
      </div>
  -->
        <div class="field medium-3 columns">
          <%= form.label :upload_attendance %>
          <%= form.file_field :file, :class=> 'attendance-file' %>
        </div>

        <div class="field medium-6 columns">
          <%= form.label :attendance_month %>
          <%= form.date_select :attendance_month, { :discard_day => true, :discard_month => false, :discard_year => false },:class => 'datetime' %>
        </div>

Aucun commentaire:

Enregistrer un commentaire