Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Attempt One
- <%= link_to_remote(image_tag('button_details.gif', :id => "details"), :update => "results",
- :url => {:controller => "masters", :action => "show"})
- %>
- ## Attempt One Console
- Parameters: {"action"=>"show", "controller"=>"masters"}
- ActiveRecord::RecordNotFound (Couldn't find Master without an ID)
- ## Attempt Two
- <%= link_to_remote(image_tag('button_details.gif', :id => "details"), :update => "results",
- :url => {:controller => "masters", :action => "show", :id => contact.id}) %>
- ## Attempt Two Console
- Parameters: {"action"=>"4", "controller"=>"masters"}
- ActionController::UnknownAction (No action responded to 4):
- ## Controller
- def show
- user = User.find(current_user.id)
- @master = user.masters.find(params[:id])
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @master }
- end
- end
- ## Routes.rb
- ActionController::Routing::Routes.draw do |map|
- map.resources :masters
- map.resources :contacts
- map.resources :users
- map.resource :session
- map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil
- map.signup '/signup', :controller => 'users', :action => 'new'
- map.login '/login', :controller => 'sessions', :action => 'new'
- map.logout '/logout', :controller => 'sessions', :action => 'destroy'
- # The priority is based upon order of creation: first created -> highest priority.
- # Sample of regular route:
- # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
- # Keep in mind you can assign values other than :controller and :action
- # Sample of named route:
- # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
- # This route can be invoked with purchase_url(:id => product.id)
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # map.resources :products
- # Sample resource route with options:
- # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
- # Sample resource route with sub-resources:
- # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
- # Sample resource route within a namespace:
- # map.namespace :admin do |admin|
- # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
- # admin.resources :products
- # end
- # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- # map.root :controller => "welcome"
- # See how all your routes lay out with "rake routes"
- # Install the default routes as the lowest priority.
- map.connect ':controller/:action/:id'
- map.connect ':controller/:action/:id.:format'
- end
- ## rake routes results, where relevant
- masters GET /masters {:controller=>"masters", :action=>"index"}
- formatted_masters GET /masters.:format {:controller=>"masters", :action=>"index"}
- POST /masters {:controller=>"masters", :action=>"create"}
- POST /masters.:format {:controller=>"masters", :action=>"create"}
- new_master GET /masters/new {:controller=>"masters", :action=>"new"}
- formatted_new_master GET /masters/new.:format {:controller=>"masters", :action=>"new"}
- edit_master GET /masters/:id/edit {:controller=>"masters", :action=>"edit"}
- formatted_edit_master GET /masters/:id/edit.:format {:controller=>"masters", :action=>"edit"}
- master GET /masters/:id {:controller=>"masters", :action=>"show"}
- formatted_master GET /masters/:id.:format {:controller=>"masters", :action=>"show"}
- PUT /masters/:id {:controller=>"masters", :action=>"update"}
- PUT /masters/:id.:format {:controller=>"masters", :action=>"update"}
- DELETE /masters/:id {:controller=>"masters", :action=>"destroy"}
- DELETE /masters/:id.:format {:controller=>"masters", :action=>"destroy"}
Add Comment
Please, Sign In to add comment