我正在使用此处找到的 twitter Boostraps 选项卡功能:http: //twitter.github.com/bootstrap/components.html#navs
在这个导航内容窗口中,我试图呈现一个显示“课程”的视图。在 views/courses/_show.html.erb 中找到的视图如下所示:
<div class="center hero-unit">
<h1><%= @course.course_name %></h1>
<%= link_to 'New Question Set',new_answer_path(:course_ID => @course.id), :class => "btn btn-large btn-primary" %>
<%= link_to 'Launch Session!', edit_course_path, :class => "btn btn-large btn-primary" %>
</div>
我正在尝试渲染它并在views/instructor/show.html.erb中使用以下代码失败
<% courses.each do |c| %>
<div class="tab-pane" id="<%=c.course_name%>">
<%= render :partial => 'courses/show', :locals => {@course=>c} %>
</div>
我收到以下错误:
/app/views/courses/_show.html.erb:1:语法错误,意外'=',期待keyword_end ...tput_buffer = @output_buffer;= local_assigns[:];show = loca... ... ^ /app/views/courses/_show.html.erb:1:语法错误,意外']',需要 tSTRING_CONTENT 或 tSTRING_DBEG 或 tSTRING_DVAR 或 tSTRING_END ... tput_buffer;= local_assigns[:];show = local_assigns[:show];... ...
说它在我的课程/_show.html.erb 的第 1 行失败了
我的课程控制器如下所示:
class CoursesController < ApplicationController
# GET /courses
# GET /courses.json
def index
@courses = Course.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @courses }
end
end
# GET /courses/1
# GET /courses/1.json
def show
@course = Course.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @course }
end
end
# GET /courses/new
# GET /courses/new.json
def new
@course = Course.new(instructor_ID: params[:instructor_ID])
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @course }
end
end
# GET /courses/1/edit
def edit
@course = Course.find(params[:id])
end
# POST /courses
# POST /courses.json
def create
@course = Course.new(params[:course])
respond_to do |format|
if @course.save
format.html { redirect_to @course, :notice => 'Course was successfully created.' }
format.json { render :json => @course, :status => :created, :location => @course }
else
format.html { render :action => "new" }
format.json { render :json => @course.errors, :status => :unprocessable_entity }
end
end
end
# PUT /courses/1
# PUT /courses/1.json
def update
@course = Course.find(params[:id])
respond_to do |format|
if @course.update_attributes(params[:course])
format.html { redirect_to @course, :notice => 'Course was successfully updated.' }
format.json { head :no_content }
else
format.html { render :action => "edit" }
format.json { render :json => @course.errors, :status => :unprocessable_entity }
end
end
end
注意:我在控制器中省略了一些方法,如删除以节省空间。
有任何想法吗?!