2010-06-29 94 views
0

我試圖使用this example但它不起作用。 我想這是因爲我使用淺層嵌套模型! 我得到這個錯誤:模板丟失Rails 3 CRUD淺層嵌套模型

Missing template pprojects/create with {:formats=>[:html], :handlers=>[:builder, :erb, :haml, :rjs, :rhtml, :rxml], :locale=>[:en, :en]} 

It looks like my app is trying to do HTML and no JS because my server console says the following: 

Processing by ProjectController#create as HTML 

也許我這裏有一個問題:

<%= form_for([@organization, @project], :remote => true) do |f| %> 

,或者因爲在我的控制我的加載方法不符合創建和更新兼容:

def load 
    @projects = Project.all 
    @project = Project.new 
    end 

def create 
    @project = @organization.projects.new(params[:project]) 
    if @project.save 
     flash[:notice] = "Successfully created project." 
     @projects = Project.all 
    end 
    end 

    def update 
    @project = Project.find(params[:id]) 
    if @project.update_attributes(params[:project]) 
     flash[:notice] = "Successfully updated project." 
     @projects = Project.all 
    end 

你有線索嗎? 在此先感謝

回答

0

我敢打賭,你有你的javascript_include_tags以錯誤的方式

儘量把他們放在這樣的:

// include jquery before you include rails.js file - it's very important!! 
javascript_include_tag 'path/to/jquery' 
javascript_include_tag 'path/to/rails' 

它爲我工作。

+0

你好,感謝您的回覆,但我的標籤正在工作。 – Fabien 2010-07-28 09:01:35