Why I got an error if I named my controller as "leaves" in Ruby on Rails
The scaffold command is the following
ruby script\generate scaffold Leave employee_id:integer leave_type_id:integer date:date
I know I could change the name but I just wonder why it always throws undifined new_leave_path
Glad to know your brilliant thoughts.
Below is the full details of the error:
NameErr开发者_Python百科or in Leaves#index
Showing app/views/leaves/index.html.erb where line #26 raised:
undefined local variable or method `new_leave_path' for #<ActionView::Base:0x620ea70>
Extracted source (around line #26):
23:
24: <br />
25:
26: <%= link_to 'New leave', new_leave_path %>
Application trace:
app/views/leaves/index.html.erb:26
app/controllers/leaves_controller.rb:7:in `index'
rake routes
new_leafe_path
or
map.resources :leaves, :singular => :leave
)
@insic Hi
It is just working fine on my machine. may be there are some conflicts with any gem or plugin that you might be using. Can't explicitly find out what is the exact reason, as I am a newbie to rails.
Add
#routes.rb
map.resources :leaves
精彩评论