2013-11-25 2 views
0

Я делаю заявку со всеми названиями моделей на испанском языке. У меня возникают некоторые странные проблемы, связанные с сингулярностью. Моя модель:Weird route behaivor for show view

class Artista < ActiveRecord::Base 
    attr_accessible :fecha, :foto, :instrumento, :nombre 
end 

Меня зовут модель "Артист" (художник) в единственном числе.

Контроллер:

class ArtistasController < ApplicationController 
    # GET /bandas 
    # GET /bandas.json 
    def index 
    @artistas = Artista.all 

    respond_to do |format| 
     format.html # index.html.erb 
     format.json { render json: @artistas } 
    end 
    end 

    def show 
    @artista = Artista.find(params[:id]) 

    respond_to do |format| 
     format.html # show.html.erb 
     format.json { render json: @artista } 
    end 
    end 
    def new 
    @artista = Artista.new 

    respond_to do |format| 
     format.html # new.html.erb 
     format.json { render json: @artista } 
    end 
    end 

    def edit 
    @artista = Artista.find(params[:id]) 
    end 

    def create 
    @artista = Artista.new(params[:artista]) 

    respond_to do |format| 
     if @artista.save 
format.html { redirect_to @artista, notice: 'Artista was successfully created.' } 
     format.json { render json: @artista, status: :created, location: @artista } 
     else 
     format.html { render action: "new" } 
     format.json { render json: @artista.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    def update 
    @artista = Artista.find(params[:id]) 
    respond_to do |format| 
     if @artista.update_attributes(params[:banda]) 
     format.html { redirect_to @artista, notice: 'Artista was successfully updated.' } 
     format.json { head :no_content } 
else 
     format.html { render action: "edit" } 
     format.json { render json: @artista.errors, status: :unprocessable_entity } 
     end 
    end 
end 
    def destroy 
    @artista = Artista.find(params[:id]) 
    @artista.destroy 
    respond_to do |format| 
     format.html { redirect_to artistas_url } 
     format.json { head :no_content } 
    end 
    end 
    end 

(Все это было автоматически создано с рельсами генерировать команды)

Теперь мои маршруты включают в себя следующее:

resources :artistas 

Когда я получить доступ localhost:3000/artistas все прекрасно работает. Я вижу список уже созданных aritsts. Теперь, когда я нажимаю на существующего исполнителя (или после того, как я пытаюсь создать новый, перенаправляясь на страницу исполнителя) по какой-то странной причине, он переходит в http://localhost:3000/artistum.3 (3 - это идентификатор художника, на который я нажал). Вывод для этого URL-адреса является абсолютно пустой страницей.

Я даже не набрал слова artistum. Я не знаю, откуда она взялась. Кроме того, у него есть точка вместо косой черты, чтобы отделить имя от id, поэтому я не знаю, как перенаправить его.

Я провел поиск grep в папке, содержащей все, и слово artistum существует только в файлах журнала.

Я предполагаю, что часть моей заявки считает, что «artista» - это множественное число, а «artistum» - его единственная форма.

Я добавил к своим маршрутам match '/artistum' => 'artistas#index', и это работает на странице индекса, но точка меня смущает, как это сделать для страниц показа.

Может ли кто-нибудь помочь мне? А) узнать, почему он пытается туда добраться или б) как проехать с этих страниц? Спасибо!

+0

Как работает 'link_to' для щелкать каждый отдельный' Artista' выглядеть? –

ответ

2

Вы можете попробовать это:

Добавьте к этому inflections.rb в папке config/initializers:

ActiveSupport::Inflector.inflections do |inflect| 
    inflect.plural 'artista', 'artistas' 
    inflect.irregular 'artista', 'artistas' 
end