我正在用Ruby遊戲on Rails的一所學校的項目,但現在我堅持了這個錯誤:Ruby on Rails的錯誤的form_for
未定義的方法`storylines_index_path」爲#<#:0x007ff34cca8f68>
我正在製作一個頁面,您可以在其中添加一個故事情節表單,因此我需要一個包含一些惡意內容的表單。我想使用form_for方法。但是,當添加我得到這個錯誤
這裏是我的代碼:
的意見/ new.html.erb
<% provide(:title, 'Overzicht Storylines') %>
<h1>Voeg nieuwe storyline toe</h1>
<%= form_for(@storyline) do |f| %>
<%= render 'shared/error_messages' %>
<%= f.label :title %>
<%= f.text_field :title%>
<%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
<% end %>
storylines_controller.rb
class StorylinesController < ApplicationController def index
@storylines = Storylines.find(:all) end
def show
@storyline = Storylines.find(params[:id])
end
def new
@storyline = Storylines.new end end
storylines.rb
class Storylines < ActiveRecord::Base
attr_accessible :title, :text
end
r outes.rb
StoryLine::Application.routes.draw do
get "users/new"
get "storylines/new"
resources :users
resources :storylines
resources :sessions, only: [:new, :create, :destroy]
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
root to: 'static_pages#home'
match '/help', to: 'static_pages#help'
match '/contact', to: 'static_pages#contact'
match '/about', to: 'static_pages#contact'
match '/home', to: 'static_pages#home'
end
通常它與路由和/或傳遞給'form_for'的對象有關。你可以在'new.html.erb'中發佈你的'routes.rb'和'form_for'這行嗎? –
我已添加routes.rb – RickRamone