Ruby on rails 没有与嵌套资源控制器匹配的路由错误
我的应用程序有一个问题,当我将路径student\u positions\u path放入导航栏时崩溃:S 我的Ruby on rails 没有与嵌套资源控制器匹配的路由错误,ruby-on-rails,ruby-on-rails-3.2,routing,nested,Ruby On Rails,Ruby On Rails 3.2,Routing,Nested,我的应用程序有一个问题,当我将路径student\u positions\u path放入导航栏时崩溃:S 我的route.rb中有 resources :students do resources :postulations end 我的应用程序会说这个错误 No route matches {:controller=>"postulations"} 我的观点 <% elsif student_signed_in? %> <% menu_group
route.rb中有
resources :students do
resources :postulations
end
我的应用程序会说这个错误
No route matches {:controller=>"postulations"}
我的观点
<% elsif student_signed_in? %>
<% menu_group :pull => :right do %>
<%= menu_item "Postulaciones", student_postulations_path %>
<%= menu_divider %>
<%= drop_down current_student.email do %>
<%= menu_item "Logout", destroy_student_session_path, :method => :delete %>
<% end %>
<% end %>
<% else %>
我的模型和假设:
class Student < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :nombre, :rol,
:prioridad, :resumen, :categoria, :foto
# attr_accessible :title, :body
has_many :postulations
end
class Postulation < ActiveRecord::Base
attr_accessible :status, :student_id
belongs_to :student
end
class-Student
我不明白我的错误。。。我觉得一切都好。请帮忙!:)
感谢您获得的嵌套资源路由
student_postulations GET /students/:student_id/postulations(.:format)
因此,在您的视图中,您需要使用student\u positions\u路径(@student)
student\u positions\u path
,student\u positions\u url
等帮助程序将student的一个实例作为第一个参数student\u positions\u path(@student)
,以查找student的记录
您可以从
因此,您的链接路径将是
<%= menu_item "Postulaciones", student_postulations_path(current_student) %>
谢谢!:D你在5分钟内修复了我的错误noob:)罚单绿色;)
<%= menu_item "Postulaciones", student_postulations_path(current_student) %>