J'utilise une URL conviviale.Rails friendly Url comment éviter les doublons? et routage
J'utilise ce problème quand je visite http://localhost:3000/9 il montre la même page que http://localhost:3000/vind-rejse
Ma catégorie Vind-Rejse ont l'ID de 9
Comment puis-je rails que pour répondre à http://localhost:3000/vind-rejse?
Et comment puis-je créer un lien vers konkurrancers show action?
Mon contrôleur Kategoris:
def show
@kategori = Kategori.find(params[:id])
@konkurrancer = @kategori.konkurrancers.find(:all)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @kategori }
end
end
Mon contrôleur Konkurrancers:
def show
@konkurrancer = Konkurrancer.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @konkurrancer }
end
end
Mes itinéraires:
match ':kategoris/:id' => 'konkurrancers#show'
match '/:id' => 'kategoris#show'
utilisez-vous 'def to_param # ... end'? – errorhandler
Oui protégé def assign_cached_slug \t self.cached_slug = self.name.gsub (/ \ s + /, '_') gsub (/ [^ \ w \ -] /, ''). fin def to_param self.name fin –
pourriez-vous poster votre code de contrôleur (l'action de show)? – errorhandler