Created
August 3, 2010 19:35
-
-
Save lhoBas/506996 to your computer and use it in GitHub Desktop.
Problem:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionController::RoutingError: No route matches {:action=>"destroy", :controller=>"users", :id=>#<User id: 1, first_name: "Demo", last_name: "User", email: "demo@example.com">} | |
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/route_set.rb:398:in `generate' | |
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/route_set.rb:450:in `generate' | |
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/route_set.rb:478:in `url_for' | |
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/url_for.rb:132:in `url_for' | |
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/route_set.rb:195:in `user_url' | |
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/polymorphic_routes.rb:114:in `send' | |
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/polymorphic_routes.rb:114:in `polymorphic_url' | |
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/url_for.rb:134:in `url_for' | |
from (irb):1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Project < ActiveRecord::Base | |
has_many :memberships | |
has_many :invites | |
validates :name, :presence => true | |
validates :description, :presence => true | |
attr_accessible :name, :description | |
has_friendly_id :permalink, :use_slug => true | |
def permalink | |
"#{description}:#{name}" | |
end | |
def normalize_friendly_id(string) | |
string | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyDevApp::Application.routes.draw do |map| | |
root :to => 'home#index' | |
resources :users | |
resources :projects, :only => [:new, :create] | |
get ':project_id' => 'projects#show', :constraints => { :project_id => /\w{3,24}\/\w{3,24}/ }, :as => 'project' | |
put ':project_id' => 'projects#update', :constraints => { :project_id => /\w{3,24}\/\w{3,24}/ }, :as => 'project' | |
delete ':project_id' => 'projects#destroy', :constraints => { :project_id => /\w{3,24}\/\w{3,24}/ }, :as => 'project' | |
get ':project_id/edit' => 'projects#edit', :constraints => { :project_id => /\w{3,24}\/\w{3,24}/ }, :as => 'edit_project' | |
scope ':project_id', :constraints => { :project_id => /\w{3,24}\/\w{3,24}/ }, :as => :project do | |
resources :memberships, :path => 'members' | |
resources :invites do | |
get :accept, :on => :member | |
get :deny, :on => :member | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
has_friendly_id :permalink, :use_slug => true | |
attr_accessible :first_name, :last_name | |
validates :first_name, :presence => true | |
validates :last_name, :presence => true | |
def permalink | |
"#{last_name}/#{first_name}" | |
end | |
def normalize_friendly_id(string) | |
string | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment