1
我现在面对这个错误很长时间了,我尝试了很多解决方案,但都没有工作。使我的方案明确:我不使用支架命令&手动创建 2)是在试图建立一个新的慈善未定义的方法charities_path为#<#<Class:0x000000035ab3f8>:0x0000000344f220>
错误产生的误差,整个事情 1):
Showing /home/hitesh/Rails/ReachOut/app/views/charity/_form.html.erb where line #1 raised:
undefined method `charities_path' for #<#<Class:0x000000035ab3f8>:0x0000000344f220>
Extracted source (around line #1):
1: <%= form_for(@charity) do |f| %>
2: <% if @charity.errors.any? %>
3: <div id="error_explanation">
4: <h2><%= pluralize(@charity.errors.count, "error") %> THis is where i screwed prohibited this charity from being saved:</h2>
MY _form.html.erb看起来像这样:
<%= form_for(@charity) do |f| %>
<% if @charity.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@charity.errors.count, "error") %> THis is where i screwed prohibited this charity from being saved:</h2>
<ul>
<% @charity.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
MY routes.rb中包含了一个慈善机构的进入
ReachOut::Application.routes.draw do
resources :charity
# The priority is based upon order of creation:
# first created -> highest priority.
我CharityController:
class CharityController < ApplicationController
# GET /charity/new
# GET /charity/new.json
def new
@charity = Charity.new
respond_to do |format|
format.html #new.html.erb
format.json { render json: @charity}
end
end
和我charity.rb(模型):确实包含一个慈善类
...
伙计们我试了很多东西(改变@ => :)但仍然无法消除这个错误...希望你们中的任何人都可以帮助我...我在整个系统中搜索了charities_path,并且找不到任何东西:) :(。
你能指导我如何设置路径帮助器方法......我对它很陌生。 – 2012-04-22 18:47:19
如果你是新手,并且不理解你可能遇到的问题,那么这是更好的重命名控制器。 – MikDiet 2012-04-23 05:50:51