I will answer you separately, because I think that your whole setup should be insignificant (IMO, this may not be so)
I think you should have a todos controller with a project that belongs to it,
--- Models ----------------
class Project < ActiveRecord::Base has_many :todos end class Todo < ActiveRecord::Base belongs_to :project end
---- routes ---------------
resources :projects do resources :todos do end end
---- controllers ----------
class ProjectsController <ApplicationController
end
class TodosController < ApplicationController def new @project = Project.find(params[:project_id]) @todos = @project.todos.build end end
in your view (views / todos.html.erb)
<%= @project.name %> <%= form_for([@Project, @todos]) do |f| %>
In accordance with the attitude, the project has a lot of todos, it is always clear to show the details of the project on the add todo screen, and not allow users to add new todos from the project screen.
and again, this is my personal opinion, feel free to ask any questions :)
source share