Created
February 18, 2010 03:52
-
-
Save trevmex/307323 to your computer and use it in GitHub Desktop.
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
OK, I figured it out. Dumb mistake: to create an optional format like | |
you see in `rake routes` as: | |
classify_user_asset GET /users/:user_id/assets/:id/edit/ | |
class(.:format) {:action=>"classify", :controller=>"assets"} | |
you would write: | |
map.with_options :controller => 'assets', :conditions => {:method | |
=> :get} do |assets| | |
assets.classify_user_asset '/users/:user_id/assets/:id/edit/ | |
class.:format', :action => 'classify' | |
end | |
I was writing: | |
map.with_options :controller => 'assets', :conditions => {:method | |
=> :get} do |assets| | |
assets.classify_user_asset '/users/:user_id/assets/:id/edit/ | |
class(.:format)', :action => 'classify' | |
end | |
because that is what I saw in `rake routes`. | |
Sorry for the n00b question, but I am glad I figured this out. | |
Yours, | |
trv |
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 AssetsController < ApplicationController | |
#GET users/1/assets | |
def index | |
@new_asset = @user.assets.new | |
@assets = @user.assets | |
end | |
# GET /users/1/assets/edit/class | |
def edit_class | |
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
#assets-to-process.yui-g | |
- field_set_tag 'Assets to Process' do | |
- @assets.each do |asset| | |
= "My Asset" | |
= link_to 'Classify', user_classify_asset_path(@user.id), :class => 'classify-button' |
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::Routing::Routes.draw do |map| | |
# Map users and assets | |
map.resources :users, :only => [:show, :edit, :update] do |users| | |
users.resources :assets, :except => [:edit, :update] | |
# This is splitting up the edit RESTful action into three parts: classify, metadatize, and route | |
users.with_options :controller => 'assets', :conditions => {:method => :get} do |assets| | |
assets.classify_asset '/assets/:id/edit/class.:format', :action => 'edit_class' | |
assets.metadatize_asset '/assets/:id/edit/metadata.:format', :action => 'edit_metadata' | |
assets.route_asset '/assets/:id/edit/route.:format', :action => 'edit_route' | |
end | |
# This is splitting up the update RESTful action into three parts: classify, metadatize, and route | |
users.with_options :controller => 'assets', :conditions => {:method => :put} do |assets| | |
assets.connect '/assets/:id/class.:format', :action => 'update_class' | |
assets.connect '/assets/:id/metadata.:format', :action => 'update_metadata' | |
assets.connect '/assets/:id/route.:format', :action => 'update_route' | |
end | |
end | |
# Map login and logout | |
map.resource :user_session, :only => [:new, :create, :destroy] | |
# Map the root url to the login page | |
map.root :controller => "user_sessions", :action => "new", :conditions => {:method => :get} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment