我正在尝试使基本表格起作用并且正在苦苦挣扎,因为我不断收到错误
undefined method `profiles_index_path' for #<#<Class:0x4fe1ba8>:0x4fccda0>
我已经检查过了,似乎无法弄清楚我哪里出错了。
在我看来(new.html.erb)我有:
<%= form_for @profile do |f| %>
<%= f.text_field :name %>
<%= f.text_field :city %>
<%= f.text_field :country %>
<%= f.text_field :about %>
<%= f.submit "Create Profile" %>
<% end %>
在我的个人资料控制器中,我有:
class ProfilesController < ApplicationController
def new
@title = "New Profile"
@profile = Profiles.new
end
def create
@user = current_user
@profile = @user.profiles.new(params[:profile])
if @profile.save
redirect_to profile_path, :notice => "Welcome to your new profile!"
else
render "profiles#new"
end
end
def edit
@user = current_user
@profile = @user.profiles.find(params[:id])
end
def update
@title = "Update Profile"
@user = current_user
@profile = @user.profiles.find(params[:id])
if @profile.update_attributes(params[:profile])
redirect_to profile_path
else
render action: "edit"
end
end
def index
@user = current_user
@profile = @user.profiles.all
@title = "Profile"
end
end
最后在我的个人资料模型中,我有
class Profiles < ActiveRecord::Base
belongs_to :user
end
人们可以提供的任何帮助真的将不胜感激,因为我很难过。:)
抱歉忘记包含路线:
controller :profiles do
get "newprofile" => "profiles#new"
get "updateprofile" => "profiles#update"
get "profile" => "profiles#home"
end
resources :profiles, :controller => 'profiles'