이 page!의 튜토리얼을 사용하여 포럼 페이지를 구현하려고합니다! 여기 포럼은 모델입니다.rails - 포럼에 대한 정의되지 않은 메소드 : 모듈
class ForumsController < ApplicationController
before_filter :admin_required, :except => [:index, :show]
def index
@forums = Forum.all
end
def show
@forum = Forum.find(params[:id])
end
def new
@forum = Forum.new
end
def create
@forum = Forum.new(params[:forum])
if @forum.save
redirect_to @forum, :notice => "Successfully created forum."
else
render :action => 'new'
end
end
def edit
@forum = Forum.find(params[:id])
end
def update
@forum = Forum.find(params[:id])
if @forum.update_attributes(params[:forum])
redirect_to @forum, :notice => "Successfully updated forum."
else
render :action => 'edit'
end
end
def destroy
@forum = Forum.find(params[:id])
@forum.destroy
redirect_to forums_url, :notice => "Successfully destroyed forum."
end
end
오류는 다음과 같습니다 :이 오류를 해결할 수있는 방법
class Forum < ActiveRecord::Base
attr_accessible :name, :description
has_many :topics, :dependent => :destroy
#method to find the most recent forum topics
def most_recent_post
topic = Topic.first(:order => 'last_post_at DESC', :conditions => ['forum_id = ?', self.id])
return topic
end
end
: 여기
undefined method `all' for Forum:Module
(일부 모델/forum.rb) 포럼의 모델이 컨트롤러 코드 ? 나는 ROR에 익숙하지 않고이 오류에 대한 적절한 해결책을 찾을 수 없다.
제발, 귀하의 포럼 모델 소스 코드를 제공하십시오 –
다시 실행 4 단계. 포럼은 모듈이 아니라 응용 프로그램/모델의 모델 – TheIrishGuy
에 있습니다. @ThelrishGuy 질문에 실수 한 것에 대해 유감스럽게 생각합니다. – trialError