Hi Mark,
I’m a newbie too, but I think I might be able to help a bit. In the
book, “Rails 2: New features for you applications”, Ryan Daigle writes
about namespaces:
Namespaces
You can now declare a routing namespace using in a RESTful manner
with map.namespace. The most common use of this is for establishing
an administrative section of an application.
map.namespace(:admin) do |admin|
admin.resources :posts
end
With this routing definition, you get the standard host of post routes
and URL helpers, all prefixed with admin:
- admin_posts – /admin/posts
- admin_post(post) – /admin/posts/:id
- formatted_admin_post(post, format) – /admin/posts/:id.:format
- new_admin_post – /admin/posts/new
- edit_admin_post(post) – /admin/posts/:id/edit
- etc.
With this namespace, the routing mechanism will try to find a controller
named Admin::PostsController to satisfy these URLs.
So, the admin namespace mapping doesn’t generate URL helpers for
products without including “admin” somewhere.
I think edit_project_path(project) should be
edit_admin_project_path(post).
But like I said, I’m still just getting the hang of Rails so don’t quote
me on that. Maybe one the more experienced guys here can help further.
Mark K. wrote:
Hi list,
I am tracking radiant svn and am setting up a new extension following
the tutorial.
I have the extension loading up and am using scaffold generated by rails
2.
The problem i am having is that i get a lot of
undefined method `project_path’ for #ActionView::Base:0x34205ec
errors.
Not being very good at routing i was hoping someone could help.
in my routes i have
define_routes do |map|
map.namespace(:admin) do |admin|
admin.resources :projects
end
end
rake routes shows they are set up correctly, but if i include something
like (this is stock rails scaffold)
<%=h project.name %> |
<%=h project.mailing_list %> |
<%= link_to 'Show', project %> |
<%= link_to 'Edit', edit_project_path(project) %> |
<%= link_to 'Destroy', project, :confirm => 'Are you sure?',
:method => :delete %> |
It gives me the above error.
Anyone have an idea? does map.resources work with extensions or am i
going to have to wright named routes instead?
Thanks
Mark K.