我在尝试遵循这里的教程时得到这个错误
http://jimneath.org/2008/06/03/converting-videos-with-rails-converting-the-video.html我有一个名为视频的表,需要作为教程所说的字段,但是当试图在浏览器中获得索引时,我有这个丑陋的错误。如何解决这个问题?谢谢。
NoMethodError in VideosController#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
我也遇到过同样的问题。
我通过从另一个工作项目plugins中复制目录acts_as_state_machine解决了这个问题
希望有帮助。
Dat