11 May 2007

Do not forget to set up the routes when using the REST Controller generator

NameError in Contact#index

Showing app/views/contact/index.rhtml where line #18 raised:

undefined local variable or method `new_contact_path' for #<#<Class:0xb768e1bc>:0xb768e194>

Extracted source (around line #18):

15: 
16: <br />
17:
18: <%= link_to 'New contact', new_contact_path %>

RAILS_ROOT: script/../config/..

Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/app/views/contact/index.rhtml:18:in `_run_rhtml_47app47views47contact47index46rhtml'
app/controllers/contact_controller.rb:6:in `index'
app/controllers/contact_controller.rb:6:in `index'

Don't forget to set up the routes.rb when using the REST Controller generator !

Edit the routes.rb and:

ActionController::Routing::Routes.draw do |map|
  # 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)

  # You can have the root of your site routed by hooking up ''
  # -- just remember to delete public/index.html.
  map.connect '', :controller => "sms", :action => 'new'

  # Allow downloading Web Service WSDL as a file with an extension
  # instead of a file named 'wsdl'
  map.connect ':controller/service.wsdl', :action => 'wsdl'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id'
 
  map.resources :contact
end

(I can't stand Zoho writer horrible interface: it's the most UNuser
friendly interface I have ever seen: you can't set the style of
the text to "normal")

No comments: