【问题标题】:Rails 3 CRUD shallow nested modelRails 3 CRUD 浅嵌套模型
【发布时间】:2010-06-29 14:45:05
【问题描述】:

我正在尝试使用this example,但它不起作用。 我想这是因为我使用了浅嵌套模型! 我收到此错误:模板丢失

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

你有线索吗? 提前致谢

【问题讨论】:

    标签: ruby-on-rails nested ruby-on-rails-3 nested-forms


    【解决方案1】:

    我敢打赌你的 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'
    

    它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 2012-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多