Bonjour
pour tester rails 2 et le REST je m’entraine à recérer une petite
application de carnet d’adresse
avec des correspondants qui dépendant de villes et de categories
J’ai donc monté mon application avec migrations et un scaffold initial
pour
correspondant, puis copier/coller et modifier pour les vues des autres
(villes et categories)
Mais voici qu’avec le même code tout fonctionne sauf pour categories où
new
/ edit / delete / show (mais pas index …) me renvoient une belle
erreur
“uninitialized constant CategorieController”
voivi le code très classique en dessous
Je sens le truc bête …
merci
NG
class CategoriesController < ApplicationController
def index
@categories = Categorie.find(:all, :order => ‘nom asc’)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @categories }
end
end
def show
@categorie = Categorie.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @categorie }
end
end
def new
@categorie = Categorie.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @categorie }
end
end
def edit
@categorie = Categorie.find(params[:id])
end
def create
@categorie = Categorie.new(params[:categorie])
respond_to do |format|
if @categorie.save
flash[:notice] = 'Categorie was successfully created.'
format.html { redirect_to(categories_url) }
format.xml { render :xml => @categorie, :status => :created,
:location => @categorie }
else
format.html { render :action => “new” }
format.xml { render :xml => @categorie.errors, :status =>
:unprocessable_entity }
end
end
end
def update
@categorie = Categorie.find(params[:id])
respond_to do |format|
if @categorie.update_attributes(params[:categorie])
flash[:notice] = 'la categorie' + @categorie.nom + ' a été mise
Ã
jour.’
format.html { redirect_to(categories_url) }
format.xml { head :ok }
else
format.html { render :action => “edit” }
format.xml { render :xml => @categorie.errors, :status =>
:unprocessable_entity }
end
end
end
def destroy
@categorie = Categorie.find(params[:id])
@categorie.destroy
respond_to do |format|
format.html { redirect_to(categories_url) }
format.xml { head :ok }
end
end
end