2011-10-19 2 views
1

Je reçois cette erreur en essayant de suivre un tutoriel icirails acts_as_state_machine aucune erreur de méthode

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

J'ai la table appelée vidéos avec le champ nécessaire comme le dit tutoriel, mais en essayant d'obtenir l'index dans le navigateur, j'ai cette erreur laide. Comment cela peut-il être résolu? Merci.

NoMethodError dans l'index VideosController de #

undefined method `acts_as_state_machine' for #<Class:0xb5a5f5b8> 

Trace application | Trace de cadre | Trace complète

app/models/video.rb:9 
app/controllers/videos_controller.rb:3:in `index' 

vidéos contrôleur

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

Vous souvenez-vous d'installer 'acts_as_state_machine'? – jdl

+0

Oui, je l'ai fait .. gem installer acts_as_state_machine et gem installer aasm .. de toute façon, je reçois cette erreur .. bien, dois-je l'avoir dans un fichier gem? – rmagnum2002

Répondre

0

J'ai eu le même problème.

Je l'ai résolu par acts_as_state_machine répertoire de copie d'un autre projet de travail \ plugins

Hope this aide.

Dat

Questions connexes