daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Attempt One
  2. <%= link_to_remote(image_tag('button_details.gif', :id => "details"), :update => "results",
  3.            :url => {:controller => "masters", :action => "show"})
  4. %>
  5.  
  6. ## Attempt One Console
  7.  
  8. Parameters: {"action"=>"show", "controller"=>"masters"}
  9. ActiveRecord::RecordNotFound (Couldn't find Master without an ID)
  10.  
  11. ## Attempt Two
  12. <%= link_to_remote(image_tag('button_details.gif', :id => "details"), :update => "results",
  13.            :url => {:controller => "masters", :action => "show",  :id => contact.id})               %>
  14.  
  15. ## Attempt Two Console
  16.  
  17. Parameters: {"action"=>"4", "controller"=>"masters"}
  18. ActionController::UnknownAction (No action responded to 4):
  19.  
  20. ## Controller
  21.  
  22.   def show
  23.    
  24.     user = User.find(current_user.id)
  25.     @master = user.masters.find(params[:id])
  26.  
  27.     respond_to do |format|
  28.       format.html # show.html.erb
  29.       format.xml  { render :xml => @master }
  30.     end
  31.   end
  32.  
  33. ## Routes.rb
  34.  
  35. ActionController::Routing::Routes.draw do |map|
  36.  
  37.   map.resources :masters
  38.  
  39.   map.resources :contacts
  40.  
  41.   map.resources :users
  42.  
  43.   map.resource :session
  44.  
  45.   map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil
  46.   map.signup '/signup', :controller => 'users', :action => 'new'
  47.   map.login '/login', :controller => 'sessions', :action => 'new'
  48.   map.logout '/logout', :controller => 'sessions', :action => 'destroy'
  49.  
  50.   # The priority is based upon order of creation: first created -> highest priority.
  51.  
  52.   # Sample of regular route:
  53.   #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  54.   # Keep in mind you can assign values other than :controller and :action
  55.  
  56.   # Sample of named route:
  57.   #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  58.   # This route can be invoked with purchase_url(:id => product.id)
  59.  
  60.   # Sample resource route (maps HTTP verbs to controller actions automatically):
  61.   #   map.resources :products
  62.  
  63.   # Sample resource route with options:
  64.   #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
  65.  
  66.   # Sample resource route with sub-resources:
  67.   #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
  68.  
  69.   # Sample resource route within a namespace:
  70.   #   map.namespace :admin do |admin|
  71.   #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  72.   #     admin.resources :products
  73.   #   end
  74.  
  75.   # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  76.   # map.root :controller => "welcome"
  77.  
  78.   # See how all your routes lay out with "rake routes"
  79.  
  80.   # Install the default routes as the lowest priority.
  81.   map.connect ':controller/:action/:id'
  82.   map.connect ':controller/:action/:id.:format'
  83. end
  84.  
  85. ## rake routes results, where relevant
  86.  
  87.                  masters GET    /masters                         {:controller=>"masters", :action=>"index"}
  88.        formatted_masters GET    /masters.:format                 {:controller=>"masters", :action=>"index"}
  89.                          POST   /masters                         {:controller=>"masters", :action=>"create"}
  90.                          POST   /masters.:format                 {:controller=>"masters", :action=>"create"}
  91.               new_master GET    /masters/new                     {:controller=>"masters", :action=>"new"}
  92.     formatted_new_master GET    /masters/new.:format             {:controller=>"masters", :action=>"new"}
  93.              edit_master GET    /masters/:id/edit                {:controller=>"masters", :action=>"edit"}
  94.    formatted_edit_master GET    /masters/:id/edit.:format        {:controller=>"masters", :action=>"edit"}
  95.                   master GET    /masters/:id                     {:controller=>"masters", :action=>"show"}
  96.         formatted_master GET    /masters/:id.:format             {:controller=>"masters", :action=>"show"}
  97.                          PUT    /masters/:id                     {:controller=>"masters", :action=>"update"}
  98.                          PUT    /masters/:id.:format             {:controller=>"masters", :action=>"update"}
  99.                          DELETE /masters/:id                     {:controller=>"masters", :action=>"destroy"}
  100.                          DELETE /masters/:id.:format             {:controller=>"masters", :action=>"destroy"}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top