Я пытаюсь получить основную форму, чтобы работать, и я изо всех сил, потому что я получаю ошибкуне определен метод ..._ index_path Ruby On Rails
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'
do 'rake routes', чтобы проверить правильный путь к методу' index' – Bongs
Как выглядит ваш файл 'routes.rb'? – Soup
Эй, я добавил свой файл соответствующих маршрутов, чтобы вы могли видеть, что у меня есть. Вид также называется new.html.erb, потому что он предназначен для создания новых профилей. Спасибо –