2

(我是法国人)我的 Rails (3.2.11) 应用程序有问题。当我用一些名词设置路线时,它不起作用!我解释:

Way::Application.routes.draw do
  scope(:path_names => { :new => "nouveau", :edit => "edition" }) do

    scope "/admin" do
      resources :news, except: [:show, :index], path: '/articles'
      resources :users, except: [:show]
      resources :pages, except: [:show]
      resources :events, except: [:show, :index]
      resources :projects, except: [:show,:index], path: '/projets'
      resources :galleries, except: [:index, :show] do 
        resources :paintings, except: [:index, :show]
      end
   end
end

结尾

当我将资源设置为“/projets”时,资源:projects 不起作用。不起作用的是:当我想在我的表单中创建一个新项目时,我点击提交,它只是将我重定向到“/projets”,而不做任何事情!但是,例如,当我将路线设置为“/ poneys”时,它可以工作!我真的不明白。谢谢你的帮助。

https://github.com/khcr/way

class ProjectsController < ApplicationController

  def new
   @project = Project.new
   render layout: 'admin'
  end

  def create 
    @project = Project.new(params[:project])
    if @project.save
      flash[:success] = "Projet créé"
      redirect_to project_path(@project)
    else
      render 'new', layout: 'admin'
    end
  end
end
4

0 回答 0