Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

example code fails

#4

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....

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

State: new
Milestone: none
Assigned to: Scott Barron Scott Barron

Activity

  1. Matt Hodgson
    Matt Hodgson

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

    July 29th, 2008 @ 11:10 PM

  2. Scott Barron
    Scott Barron

    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

    July 30th, 2008 @ 09:37 AM

  3. todd (at snappl)
    todd (at snappl)

    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.

    February 4th, 2009 @ 02:04 PM

  4. todd (at snappl)
    todd (at snappl)

    Oh, yeah, forgot, if I add

    aasm_state :pending

    to the User model, nothing happens, same error.

    February 4th, 2009 @ 02:09 PM

  5. todd (at snappl)
    todd (at snappl)

    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.

    February 4th, 2009 @ 02:19 PM

  6. todd (at snappl)
    todd (at snappl)

    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.

    February 4th, 2009 @ 02:27 PM

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.