【问题标题】:rails acts_as_state_machine no method errorrails act_as_state_machine 没有方法错误
【发布时间】:2011-10-19 00:43:43
【问题描述】:

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

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

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

视频控制器中的 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

【问题讨论】:

  • 你记得安装acts_as_state_machine吗?
  • 是的,我这样做了.. gem installacts_as_state_machine 和 gem install aasm.. 无论如何,我得到了这个错误.. 好吧,我应该把他放在 gem 文件中吗?

标签: ruby-on-rails acts-as-state-machine


【解决方案1】:

我遇到了同样的问题。

我通过从另一个工作项目\插件复制目录acts_as_state_machine解决了这个问题

希望对您有所帮助。

日期

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-17
    • 2014-03-26
    • 2013-11-15
    • 1970-01-01
    • 1970-01-01
    • 2013-02-03
    • 2020-11-06
    • 1970-01-01
    相关资源
    最近更新 更多