【发布时间】:2016-08-19 19:59:56
【问题描述】:
这是subject_controller
class SubjectsController < ApplicationController
layout false
def index
@subjects = Subject.order("position ASC")
end
def show
@subject = Subject.find(params[:id])
end
def new
end
def edit
end
def delet
end
end
这是“show.html.erb”
<%= link_to("<< Back to List", {:class => 'index'}) :class => 'back- link)'%>
<div class ="subjects show">
<h2>Show Subject</h2>
<table sammary="Subject detail view">
<tr>
<th>Name</th>
<td><%= @subject.name %></td>
</tr>
<tr>
<th>Position</th>
<td><%= @subject.position %> </th>
</tr>
<tr>
<th>Visible</th>
<td><%= @subject.visible ? 'true': 'flse' %> </th>
</tr>
<tr>
<th>Created</th>
<td><%= @subject.created_at %> </th>
</tr>
<tr>
<th>Updated</th>
<td><%= @subject.updated_at %> </th>
</tr>
</table>
</div>
所以当我在浏览器上单击某些东西时,我什么也没有得到,而当我在 Rails 控制台上这样做时
Subject.find(params[:id])
我收到这条消息
NameError: undefined local variable or method `params' for main:Object from (irb):7
【问题讨论】:
-
因为 irb/console 不知道 params 是什么。
标签: ruby-on-rails ruby