1

我在尝试按照此处的教程进行操作时遇到此错误

http://jimneath.org/2008/06/03/converting-videos-with-rails-converting-the-video.html

正如教程所说,我有一张名为视频的表格,需要字段,但是当试图在浏览器中获取索引时,我遇到了这个丑陋的错误。如何解决?谢谢。

VideosController#index 中的 NoMethodError

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

视频.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
4

1 回答 1

0

我有同样的问题。

我通过从另一个工作项目\插件复制目录acts_as_state_machine来解决它

希望这有帮助。

数据

于 2012-01-06T07:38:59.457 回答