Ruby on rails 在RubyonRails中创建视图
我试图在RubyonRails应用程序中创建一个视图,这给了我以下错误 对不起,您不允许访问该页面。 我不知道该怎么解决这个错误 我将以下内容添加到Ruby on rails 在RubyonRails中创建视图,ruby-on-rails,Ruby On Rails,我试图在RubyonRails应用程序中创建一个视图,这给了我以下错误 对不起,您不允许访问该页面。 我不知道该怎么解决这个错误 我将以下内容添加到student\u controller.rb def generate_id_card @student = Student.find(params[:id]) @guardian = Guardian.find(params[:id]) @address = @student.address_line1.to_s
student\u 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
查看页面为:
</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>
:正常)%>
您正在处理的项目有一些授权规则。您需要使用它们:您是否使用某种身份验证/授权?gem或您自己的定制解决方案提供的任何信息?嘿,也许我们需要更多的信息来帮助您。是否要呈现pdf格式?那么你用什么宝石呢?或者你自己试试?为什么你的控制器是student_controller.rb而不是studentS_controller.rb?模板文件的名称是什么?你有合适的管理层吗?也许是来自应用程序_controller.rb中designe的authenticate_用户?很抱歉Krzysztof没有得到它,但是我想在一个应用程序中添加这个视图,但其他人没有。我有源代码。应用程序名是Fedena开源。是的,我想使用gem wkhtmltopdf呈现为pdf