#4 new
fairchild

example code fails

Reported by fairchild | July 29th, 2008 @ 05:36 PM

when following the instruction in the readme (installing the gem) and then pasting the example code into a test_aasm.rb file the sample code fails.

uninitialized constant Conversation::AASM

thsi happens even with

require 'rubygems'

gem 'rubyist-aasm'

added to the file.

Perhaps there is something on my system, but it appears that others are having the problem also:

http://railsforum.com/viewtopic....

Comments and changes to this ticket

  • Matt Hodgson

    Matt Hodgson July 29th, 2008 @ 11:10 PM

    Ditto on this. Can't get it to include for the life of me. Tried it every way I can think of.

  • Scott Barron

    Scott Barron July 30th, 2008 @ 09:37 AM

    Hi,

    Can you guys tell me a little about your set up and give some specific examples of what's failing? Here's what I've got that's working for me:

    ~ > sudo gem install rubyist-aasm

    Successfully installed rubyist-aasm-2.0.2

    1 gem installed

    Installing ri documentation for rubyist-aasm-2.0.2...

    Installing RDoc documentation for rubyist-aasm-2.0.2...

    ~ > irb

    >> require 'rubygems'

    => false

    >> require 'aasm'

    => true

    >> class Conversation

    >> include AASM

    >> aasm_initial_state :new

    >> aasm_state :new

    >> aasm_state :read

    >> aasm_event :view do

    ?> transitions :to => :read, :from => [:new]

    >> end

    >> end

    => #

    >> Conversation.new.view!

    => true

  • todd (at snappl)

    todd (at snappl) February 4th, 2009 @ 02:04 PM

    I'm getting this as well.

    In my environment.rb:

    require 'aasm'

    Rails::Initializer.run do |config| ... config.gem "rubyist-aasm", :lib => "aasm", :source => "http://gems.github.com", :version => '2.0.5'

    In my model:

    class User < ActiveRecord::Base

    include AASM
    
    aasm_initial_state :pending
    
    

    in my spec:

    it "should start in pending state" do

    g = User.create(@valid_attributes)
    g.pending?.should_be true
    
    

    end

    error when I run the spec:

    undefined method aasm_state' for #<User:0x22fc6bc>

    Environment OSX 10.5.6, Rails 2.2.2, Ruby 1.8.6 from macports. Many gems installed, but right now only requiring haml 2.0.7 concomitantly. Never been able to make aasm work on any project, and so have always used acts_as_state_machine, but now cannot get it installed owing to a refusal to contact the errtheblog subversion server.

  • todd (at snappl)

    todd (at snappl) February 4th, 2009 @ 02:09 PM

    Oh, yeah, forgot, if I add

    aasm_state :pending

    to the User model, nothing happens, same error.

  • todd (at snappl)

    todd (at snappl) February 4th, 2009 @ 02:19 PM

    Got it. I froze the gem in to vendor/gems and added:

    aasm_column :state

    (surely that's the default)

    to my model. However, @user.current_state does not work, it will only work with the more verbose @user.aasm_current_state. Also the lovely, concise @user.pending? @user.active?, etc. methods available in acts_as_... are either gone or not working.

    Please don't take this the wrong way, but overall aasm feels a bit unfinished in contrast with acts_as_state_machine.

  • todd (at snappl)

    todd (at snappl) February 4th, 2009 @ 02:27 PM

    Sorry, disregard that last comment (at least most of it): @user.pending? .active? etc. are working. I was being stoopid.

    Would still like to see a default column name, however.

  • Alex Veer
  • Alex Veer
  • Alex Veer

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Library for adding state machines to Ruby classes. Includes persistence layers for things like ActiveRecord. Formerly known as acts_as_state_machine.

People watching this ticket

Attachments

Pages