我的问题是,如果我想测试编辑表格,我总是会得到这个例外。Rails表格编辑表格
你能帮我弄清楚这个问题吗?
这是错误消息:
undefined method `model_name' for NilClass:Class
Extracted source (around line #5):
2: <div class="row">
3: <div class="box">
4: <span id="logo">Azubiware 2.0</span><br><br>
5: <%= form_for(@bsinfo) do |f| %>
6: <% @basedate = Date.new(@bsinfo.year) %>
7: <% @basedate = @basedate.beginning_of_year %>
8: <% @basedate = @basedate.beginning_of_week %>
我有同样的形式与我的用户表去,这正常工作......
class BsinfosController < ApplicationController
def index
@title = "Verwaltung Abwesehnheiten"
end
def new
@title = "Sign up"
@bsinfo = Bsinfo.new
end
def show
@bsinfo = Bsinfo.find(params[:id])
@title = @bsinfo.year
end
def create
@bsinfo = Bsinfo.new(params[:bsinfo])
if @bsinfo.save
flash[:success] = "Schedule successfull created"
redirect_to bsinfos_path
else
render 'new'
end
end
def edit
@title = "Settings"
end
def update
if @bsinfo.update_attributes(params[:bsinfo])
flash[:success] = "Profile successfull updated"
redirect_to @bsinfo
else
render 'edit'
end
end
def destroy
Bsinfo.find(params[:id]).destroy
flash[:success] = "Scheduel destroyed"
redirect_to bsinfos_path
end
end
和链接到编辑的形式是像
<% @bs = Bsinfo.all %>
<% @bs.each do |bsall| %>
<%= link_to "#{bsall.name}", edit_bsinfo_path(bsall), :class => "btn" %>
<% end %>
的URL看起来像 本地主机:3000/bsinfos/17 /编辑
您可以发布您的控制器代码请 – edralph 2012-07-09 20:58:40