1

iはアルバムコントローラとモデルのいずれかの解決策については、この未定義のメソッドを取得しています...未定義のメソッドActiveRecordのための `MODEL_NAME「

未定義のメソッド` MODEL_NAME?」::関連:クラス

線を中心に抽出されたソース( #6):

3:>>

4:新しいアルバム

5:

6:= form_for @albums do | f |

7:= f.error_messages

8:%のP

9:= f.label:NAME


=link_to 'albums', albums_path 
     >> 
     new album 
    = form_for @album do |f| 
     = f.error_messages 
    %p 
    = f.label :name 
    = f.text_field :name 

    %p 
    = f.label :description 
    = f.text_field :description, :rows => 3 
    %p 
    = f.submit 

%p= link_to "Back to List", albums_path 

class AlbumsController < ApplicationController 
    before_filter :authenticate_user! 

    respond_to :html 
    respond_to :json 

    def index 
    @albums = current_user.albums.paginate :page => params[:page], :per_page => 9, :order => 'created_at DESC' 
    respond_with @albums, :aspect => @aspect 
    end 

    def create 
    aspect = params[:album][:to] 

    @album = current_user.post(:album, params[:album]) 
    if @album.persisted? 
     redirect_to :action => :show, :id => @album.id, :aspect => aspect 
    else 
     redirect_to albums_path(:aspect => aspect) 
    end 
    end 

    def new 
    @album = Album.new 
    end 

    def destroy 
    @album = current_user.find_visible_post_by_id params[:id] 
    @album.destroy 
    respond_with :location => albums_url 
    end 

    def show 
    @person = current_user.visible_people.find_by_person_id(params[:person_id]) if params[:person_id] 
    @person ||= current_user.person 

    @album = :uploads if params[:id] == "uploads" 
    @album ||= current_user.find_visible_post_by_id(params[:id]) 

    unless @album 
     render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 
    else 

     if @album == :uploads 
     @album_id = nil 
     @album_name = "Uploads" 
     @album_photos = current_user.visible_posts(:_type => "Photo", :album_id => nil, :person_id => @person.id) 

     else 
     @album_id = @album.id 
     @album_name = @album.name 
     @album_photos = @album.photos 
     end 

     respond_with @album 
    end 
    end 

    def edit 
    @album = current_user.find_visible_post_by_id params[:id] 
    redirect_to @album unless current_user.owns? @album 
    end 

    def update 
    @album = current_user.find_visible_post_by_id params[:id] 

    if current_user.update_post(@album, params[:album]) 
     respond_with @album 
    else 
     render :action => :edit 
    end 
    end 

end 

このエラーが起こっているとき0

答えて

2
=form_for @albums do |f| 

である必要があり、彼らは異なる可能性が方法がわかりませんか?新しいアクションからのエラーですか?

0

それはあなたの質問から明らかではない - あなたは半ダースのメソッドにコードを掲載しましたが、あなたは、このエラーの原因となっている1述べていません。エラーバックトレースのソースも、その直下に貼り付けたソースと一致しません。

は、どのようなエラーがあなたが ActiveModelオブジェクトのように十分に見えない何かに form_forのようなものを呼び出すようにしようとしていることを広く言っている(代わりに、あなたは意味を成さない、 form_forにスコープを渡しているように見えます) 。 form_for @albumsを実行すると、確実にこれが実行されます。 @albums対、ちょうどあなたのエラーメッセージに基づいて、ここで推測、あなたのコード例では、それが正しいよう

=form_for @album do |f| 

@album

関連する問題