简体   繁体   English

为什么我的RoR应用程序出现此错误?

[英]Why am I getting this error with my RoR app?

I get this error: 我收到此错误:

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>

I have one Video model and a videos controller with a new and create method. 我有一个Video模型和一个带有newcreate方法的video控制器。 My routes.db file has root :to => "videos#new" . 我的routes.db文件具有root :to => "videos#new" I have one view new.html.erb with this code: 我使用以下代码查看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 %>

And my controller has this: 我的控制器有这个:

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

This is all that's in my routes file: 这就是我的路线文件中的全部内容:

 Dreamstill::Application.routes.draw do
   root :to => "videos#new"
 end

your routes should be 你的路线应该是

 Dreamstill::Application.routes.draw do
   root :to => "videos#new"
   resources :videos
 end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我在我的 ROR 应用程序中得到一个未定义的方法 &#39;&lt;=&#39; - Why am I getting an undefined method '<=' for in my ROR app 为什么在DevKit安装ROR期间出现此错误 - Why am I getting this error during DevKit install for ROR 为什么我在heroku上却出现此错误,而在我的Rails应用程序中却没有开发此错误? - Why am I getting this error on heroku but not in development in my rails app? 当我在生产中部署我的 ror 应用程序时,我收到以下错误 - when I am deploy my ror application on production then I am getting following error 为什么在RoR中尝试将postgresql用作数据库时出现此错误? - Why am I getting this error when attempting to use postgresql as database in RoR? 为什么我收到由Heroku托管的全新应用程序的应用程序错误错误页面? - Why am I getting an Application Error error page for my brand new app hosted by Heroku? 为什么在Heroku上出现错误,提示我需要将应用程序迁移到Bamboo? - Why am I getting an error on Heroku that suggests I need to migrate my app to Bamboo? 尝试在Rails 4应用程序中添加电子邮件确认时,为什么会出现未定义的方法错误? - Why am I getting an an undefined method error when I try to add email confirmations in my Rails 4 app? 为什么安装引导程序后我的 Rails solidus 应用程序会出现此错误? - Why am I getting this error in my rails solidus app after installing bootstrap? 为什么我的Rails应用程序中出现未定义的方法“ comments”? - Why am I getting undefined method `comments' in my rails app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM