1
controller:
class UsuarioController < ApplicationController
def index
@usuarios = Usuario.order :nome
end
def new
@usuario = Usuario.new
end
def show
@usuario = Usuario.find(params[:id])
end
def destroy
@usuario = Usuario.find(params[:id])
@usuario.destroy
redirect_to(action: "index")
end
end
View:
New User
<%= form_for @usuario do |f| %>
Nome: <%= f.text_field :nome %><br/>
<% end %>
Error:
NoMethodError in Usuario#new
Showing /vagrant/crudexemplo/app/views/usuario/new.html.erb where line #4 raised:
undefined method `usuarios_path' for #<#<Class:0x007fce441b1e20>:0x007fce31f1e148>
Do the following check the routes using rake Routes and then glue here for us to look. rake Routes
– Thadeu Esteves Jr.