我在尝试按照此处的教程时收到此错误
http://jimneath.org/2008/06/03/converting-videos-with-rails-converting-the-video.html
我有一个名为视频的表,需要字段,如教程所说,但是当试图在浏览器中获取索引时,我有这个丑陋的错误。怎么解决这个问题?感谢。
VideosController中的NoMethodError #index
undefined method `acts_as_state_machine' for #<Class:0xb5a5f5b8>
应用程序跟踪|框架跟踪|完整跟踪
app/models/video.rb:9
app/controllers/videos_controller.rb:3:in `index'
视频控制器
class VideosController < ApplicationController
def index
@videos = Video.find :all
end
def new
@video = Video.new
end
def create
@video = Video.new(params[:video])
if @video.save
@video.convert
flash[:notice] = 'Video has been uploaded'
redirect_to :action => 'index'
else
render :action => 'new'
end
end
def show
@video = Video.find(params[:id])
end
end
video.rb
class Video < ActiveRecord::Base
# Paperclip
# http://www.thoughtbot.com/projects/paperclip
has_attached_file :source
validates_attachment_presence :source
validates_attachment_content_type :source, :content_type => 'video/quicktime'
acts_as_state_machine :initial => :pending
state :pending
state :converting
state :converted, :enter => :set_new_filename
state :error
event :convert do
transitions :from => :pending, :to => :converting
end
event :converted do
transitions :from => :converting, :to => :converted
end
event :failed do
transitions :from => :converting, :to => :error
end
答案 0 :(得分:0)
我遇到了同样的问题。
我通过复制目录acts_as_state_machine从另一个工作项目\ plugins
解决了它希望得到这个帮助。
的DAT