0
我一直在阅读this resource以及this post试图了解更多的路由(目前正在学习编程/ Rails的做法),但我想知道如何修复错误我' m得到,这是No route matches {:controller=>"profiles", :action=>"show"}
。Rails 3路由错误 - “没有路由匹配”
我得到的错误工作通过使用嵌套模型表单的Rails 3注册过程。在注册过程如下:
user = User.new
user.email = ""
user.password = ""
user.profile = Profile.new
user.profile.save
user.save
的注册过程开始于具有以下形式的主页:
<%= form_for :user, :url => signup_path, :html => {:id => 'homepage'} do |f| %>
<div>
...
</div>
<%= f.fields_for :profile do |f| %>
<% end %>
<% end %>
然后流程转向填写的个人资料,然后重定向到在此表格完成后新用户的个人资料:
<%= form_for :profile, :html => { :multipart => true } do |f| %>
<div>
...
</div>
<%= f.fields_for :user do |f| %>
<% end %>
<% end %>
我在其各自的模型中有accepts_nested_attributes_for :user and :profile
。
我的Rails服务器时,它给了我更多的细节:
ActionController::RoutingError (No route matches {:controller=>"profile.save", :action=>"show"}):
app/controllers/profiles_controller.rb:15:in `create'
所以在我ProfilesController在“创造”:
def create
@profile = Profile.new(params[:profile])
if @profile.save
redirect_to profile_path, :notice => 'User successfully added.'
else
render :action => 'new'
end
end
似乎很清楚,这个问题是profile_path
,所以我的路线.rb:
post "/signup" => "profiles#create", :as => "signup"
match "skip/signup", :to => "info#signupskip"
match "skip/profiles/new", :to => "profiles#newskip"
root :to => "users#create"
任何人都可以帮助阐明我在做什么错误/缺少在我的Routes.rb文件?
有“得”,但忘了加上特定的配置文件。谢谢! – tvalent2