Permalink
Browse files

use shallow routes to simplify URLs for subdomains

  • Loading branch information...
fortuity committed Mar 18, 2010
1 parent b630faa commit a53ab54014cb685b90636f5fb2c135c49cf33ed4
@@ -25,7 +25,7 @@ def collection
def find_user
@user = User.find(params[:user_id])
unless current_user == @user
- flash[:alert] = "You are not allowed to create or change someone else's subdomain."
+ flash[:alert] = "Are you logged in properly? You are not allowed to create or change someone else's subdomain."
redirect_to user_path(@user)
end
end
@@ -2,4 +2,4 @@
%td.name= h subdomain.try(:name)
%td.user_id= link_to subdomain.user.name, user_url(subdomain.user)
%td.actions
- = link_to 'Destroy', user_subdomain_url(subdomain.user,subdomain), :confirm => 'Are you sure?', :method => :delete
+ = link_to 'Destroy', subdomain_url(subdomain), :confirm => 'Are you sure?', :method => :delete
@@ -1,4 +1,4 @@
- content_tag_for(:tr, subdomain, :class => cycle(:odd, :even)) do
- %td.name= link_to subdomain.name, site_site_path(subdomain,subdomain)
+ %td.name= link_to site_root_path(subdomain).to_s, site_root_path(subdomain)
%td.actions
- = link_to 'Destroy', user_subdomain_url(subdomain.user,subdomain), :confirm => 'Are you sure?', :method => :delete
+ = link_to 'Destroy', subdomain_url(subdomain), :confirm => 'Are you sure?', :method => :delete
View
@@ -6,7 +6,7 @@
map.subdomain nil do |main|
main.root :controller => "home"
main.resources :users do |users|
- users.resources :subdomains, :except => [:edit, :show]
+ users.resources :subdomains, :except => [:edit, :show], :shallow => true
end
end

0 comments on commit a53ab54

Please sign in to comment.