简体   繁体   中英

Create View in Ruby on Rails

I am trying to create a view in a Ruby on Rails application, which gives me the below error

Sorry, you are not allowed to access that page. I don't know what to do to solve the error.

I added following to student_controller.rb

    def generate_id_card
    @student = Student.find(params[:id])
    @guardian = Guardian.find(params[:id])
    @address = @student.address_line1.to_s + ' ' + @student.address_line2.to_s
    render :pdf=>'generate_id_card'
    #        respond_to do |format|
    #            format.pdf { render :layout => false }
end

and the view page is:

</div>
<div id="page-yield">

  <div class="hor_line"></div>
  <h2><%= t('transfer_certificate') %></h2>
  <div class="hor_line"></div>


  <div class="extender"> </div>
  <div class="report">

    <div id="pdf-info">
     <table id="pdf-table" width="100%" cellspacing="0">
     <tr>
     <td>
     <% if @student.photo.file? %>
        <%= image_tag @student.photo.url %>
      <% else %>
        <%= image_tag "master_student/profile/default_student.png" %>
      <% end %>
     </td>
     <td>
      <table id="pdf-table" width="100%" cellspacing="0">
        <% c= 'odd' %>
        <tr class="<%= cycle(c,(["odd","even"]-[c]).first) %>">
          <td class="col-pdf"><%= t('name') %></td>
          <td class="col-pdf"> <%= @student.full_name  %> </td>
        </tr>
        <tr class="<%= cycle(c,(["odd","even"]-[c]).first) %>">
          <td class="col-pdf"><%= t('admission_no') %></td>
          <td class="col-pdf"><%= @student.admission_no %></td>
        </tr>
        <tr class="<%= cycle(c,(["odd","even"]-[c]).first) %>">
          <td class="col-pdf"><%= t('admission_date') %></td>
          <td class="col-pdf"><%= I18n.l(@student.admission_date,:format=>:normal) %></td>
        </tr>
    </table>       
      </table>
    </div>

  </div>

</div>

The project you are working on has some authorization rules. You need to make use of them: https://github.com/projectfedena/fedena/blob/master/config/authorization_rules.rb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM