语法错误,但语法正确?意外':',期待')'

时间:2013-06-11 03:16:11

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

我有一个嵌套表格(见下文)

模特艺术家(艺术家是用户)

has_many :art_works
  has_many :canvases
  accepts_nested_attributes_for :art_works //artworks is what im currently working on
   accepts_nested_attributes_for :canvases

Controller art_works

    def new
    @artist = Artist.find(params[:artist_id])
    @artwork = @artist.art_works.build
    respond_to do |format|
          format.html # new.html.erb
          format.json { render json: @artwork }
        end
      end
  def create
    @artwork = ArtWork.new(params[:artwork])
    respond_to do |format|
      if @artwork.save
        format.html { redirect_to @artwork, notice: 'artwork was successfully created.' }
        format.json { render json: @artwork, status: :created, location: @artwork }
      else
        format.html { render action: "new" }
        format.json { render json: @artwork.errors, status: :unprocessable_entity }
      end
    end
  end

艺术品观点_form

<%= form_for(@artwork, :url => artist_art_works_path(current_artist) :multipart => true) do |f| %>
<p>
    <%= f.file_field :art %>
</p>
<p>
    <%= f.submit %>
</p>
<% end %>

我非常肯定这会起作用,但我假设我:url不正确?我不确定它会是什么。下面是我的艺术品路线我之所以嵌入这些东西,是因为艺术家可以将艺术品上传到艺术品模型中,想法是在一件艺术品中加入几件艺术品(就像一张专辑里面有很多图片)

artist_art_works GET    /artists/:artist_id/art_works(.:format)                          art_works#index
                              POST   /artists/:artist_id/art_works(.:format)                          art_works#create
          new_artist_art_work GET    /artists/:artist_id/art_works/new(.:format)                      art_works#new
         edit_artist_art_work GET    /artists/:artist_id/art_works/:id/edit(.:format)                 art_works#edit
              artist_art_work GET    /artists/:artist_id/art_works/:id(.:format)                      art_works#show
                              PUT    /artists/:artist_id/art_works/:id(.:format)                      art_works#update
                              DELETE /artists/:artist_id/art_works/:id(.:format)                      art_works#destroy

非常感谢您的帮助。 (对于noobness抱歉)

1 个答案:

答案 0 :(得分:1)

你错过了一个逗号。是的错误消息没有帮助。

@artwork, :url => artist_art_works_path(current_artist) :multipart => true

VS

@artwork, :url => artist_art_works_path(current_artist), :multipart => true