Is there any way of getting the nice url methods such as new_page_path
that you get when you declare
map.resource :pages
in routes.rb?
Here is my situation:
I have a Page model with lots of pages that use acts_as_list. This
means that some of the pages are root pages - these are my site’s
sections (tabbed navigation). I would like the urls to look like this:
This will take you to a page called ‘awesome-post’ that is a child of
a page called blog. Each page has a parent page (the ‘page_id’ field
in the database).
Thanks, but wouldn’t I only do that if people and programmers were
models? The only model is pages - people and programmers are just
examples of what the pages might be, they could be anything.
I can then use params[:pages].last to grab the page with a permalink
of ‘latest’ and use its id to set the page_id of the new page. This
will mean that the new page is a child of the ‘latest’ page.
Only problem is now that I don’t know where to send the form, with
normal map.resources :pages, it was:
<% form_for(:page, :url => pages_path) do |f| %>
Do I need to write my own create route?
map.create ???
I wouldn’t even know what to put in here since it never actually goes
to an actual page, just accesses the ‘create’ action.
The only thing I don’t know how to do know is what to put in my forms
to access the ‘create’ and ‘update’ actions.
REST would have me use the same url but just using different methods
(POST and PUT respectively), how does map.resources do that???
thanks again,
DAZ
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.