我得到這個錯誤:爲什麼我的RoR應用程序出現此錯誤?
NoMethodError in Videos#new
Showing /rubyprograms/dreamstill/app/views/videos/new.html.erb where line #1 raised:
undefined method `videos_path' for #<#<Class:0x10398f8d8>:0x10398dbc8>
我有一個視頻模式,用new
和create
方法的視頻控制器。我的routes.db
文件有root :to => "videos#new"
。我有一個觀點new.html.erb
與此代碼:
<%= form_for(@video) do |f| %>
<% if @video.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@video.errors.count, "error") %> prohibited this video from being saved:</h2>
<ul>
<% @video.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :video_url %><br />
<%= f.text_field :video_url %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
我的控制器有這樣的:
def new
@video = Video.new
end
def create
@video = Video.new(params[:video])
respond_to do |format|
if @article.save
format.html #{ redirect_to(@video, :notice => 'Article was successfully created.') }
else
format.html { render :action => "new" }
end
end
end
這是所有在我的路線文件:
Dreamstill::Application.routes.draw do
root :to => "videos#new"
end
顯示您的航線 – fl00r 2011-03-12 21:28:23
確定發佈,這不是很多...這可能是爲什麼我得到這個錯誤? – 2011-03-12 21:30:35