Ok. But what if i will have following models: Video, Audio, Video::Playlist, Audio::Playlist
and resouces: video -> has_many -> video/playlists audio -> has_many -> audio/playlists On 15 янв, 17:22, "Andrew Timberlake" <and...@andrewtimberlake.com> wrote: > On Thu, Jan 15, 2009 at 3:28 PM, Dmitrij Smalko <dsma...@gmail.com> wrote: > > > Hello, > > > My controllers: > > - ForumsController > > - Forum::TopicsController > > - Forum::Topic::PostsController > > > Resources: > > > map.resources :forums do |forums| > > forums.resources :topics, :controller => "forum/topics" do |topics| > > topics.resources :posts, :controller => "forum/topic/posts" > > end > > end > > > Is it a good design? Problem is that only way to get a post path is to > > call: > > > forum_topic_post_path(post.topic.forum, post.topic, post) > > There's no need to have namespaces in your controllers > - ForumsController > - Forum::TopicsController > - Forum::Topic::PostsController > > could be > > ForumsController > TopicsController > PostsController > > and then your resources can be: > > map.resources :forums do |forums| > forums.resources :topics do |topics| > topics.resources :posts > end > end > > it will still give you long urls like /forums/1/topics/1/posts/1 > > I've done some changes to get slightly shorter urls like this: > > map.resources :forums, :as => 'f' do |forums| > forums.resources :topics, :as => 't' do |topics| > topics.resources :posts, :as 'p' > end > end > > which then makes ther urls /f/1/t/1/p/1 and then if you use to_param in your > models, you can get /f/1-my-forum/t/1-my-topic/p/1-my-post > > The to_param is done in the model > > class Forum < ActiveRecord::Base > def to_param > "#{id}-#{name.downcase.gsub(/[^0-9a-z]+/, '-')" > end > end > > -- > Andrew > Timberlakehttp://ramblingsonrails.comhttp://www.linkedin.com/in/andrewtimberlake > > "I have never let my schooling interfere with my education" - Mark Twain --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---