Search Results

Search found 8 results on 1 pages for 'aasm'.

Page 1/1 | 1 

  • Getting list of states/events from a model that AASM's

    - by Jason Nerer
    Hi, I successfully integrated the most recent AASM gem into an application, using it for the creation of a wizard. In my case I have a model order class Order < ActiveRecord::Base belongs_to :user has_one :billing_plan, :dependent => :destroy named_scope :with_user, ..... <snip> include AASM aasm_column :aasm_state aasm_initial_state :unauthenticated_user aasm_state :unauthenticated_user, :after_exit => [:set_state_completed] aasm_state : <snip> <and following the event definitions> end Now I would like to give an administrator the possibility to create his own graphs through the AASM states. Therefore I created two additional models called OrderFlow and Transition where there order_flow has many transitions and order belongs_to order_flow. No problem so far. Now I would like to give my admin the possibility to dynamically add existing transitions / events to an order_flow graph. The problem now is, that I do not find any possibility to get a list of all events / transitions out of my order model. aasm_states_for_select seems to be the correct candidate, but I cannot call it on my order model. Can anyone help? Thx in advance. J.

    Read the article

  • How do I implement aasm in Rails 3 for what I want it to do?

    - by marcamillion
    I am a Rails n00b and have been advised that in order for me to keep track of the status of my user's accounts (i.e. paid, unpaid (and therefore disabled), free trial, etc.) I should use an 'AASM' gem. So I found one that seems to be the most popular: https://github.com/rubyist/aasm But the instructions are pretty vague. I have a Users model and a Plan model. User's model manages everything you might expect (username, password, first name, etc.). Plan model manages the subscription plan that users should be assigned to (with the restrictions). So I am trying to figure out how to use the AASM gem to do what I want to do, but no clue where to start. Do I create a new model ? Then do I setup a relationship between my User model and the model for AASM ? How do I setup a relationship? As in, a user 'has_many' states ? That doesn't seem to make much sense to me. Any guidance would be really appreciated. Thanks. Edit: If anyone else is confused by AASMs like myself, here is a nice explanation of their function in Rails by the fine folks at Envy Labs: http://blog.envylabs.com/2009/08/the-rails-state-machine/ Edit2: How does this look: include AASM aasm_column :current_state aasm_state :paid aasm_state :free_trial aasm_state :disabled #this is for accounts that have exceed free trial and have not paid #aasm_state :free_acct aasm_event :pay do transitions :to => :paid, :from => [:free_trial, :disabled] transitions :to => :disabled, :from => [:free_trial, :paid] end

    Read the article

  • ruby on rails state machines

    - by srboisvert
    I'm looking to implement a state machine to manage a user moving through a series of steps over an extended period of time (weeks) with emails and then they interact with the app. I've looked at a couple of AASM plugins and forks (it seems like this plugin space has become a bit chaotic) and am curious what people would recommend. I saw the automatic AASM by hashrocket, that transitions states using cron, and from the title it looks like it might fit the bill but there doesn't appear to be any documentation anywhere and it looks more like a skeleton app than a plugin.

    Read the article

  • function not working in production mode

    - by maps
    I am using the rvideo gem to transcode files to a .flv format. class Video < ActiveRecord::Base include AASM aasm_column :status aasm_initial_state :initial aasm_state :initial aasm_state :converting, :exit => :transcode aasm_state :transfering , :exit => :send_s3 aasm_state :completed aasm_state :failed aasm_event :convert do transitions :from => [:initial], :to => :converting end aasm_event :transfer do transitions :from => [:converting], :to => :transfering end aasm_event :complete do transitions :from => [:transfering], :to => :completed end aasm_event :error do transitions :from => [:initial, :converting, :transfering, :completed] end has_attached_file :asset, :path => "uploads/:attachment/:id.:basename.:extension" def flash_path return self.asset.path + '.flv' end def flash_name return File::basename(self.asset.path)# + '.flv' end def flash_url return "#{AWS_HOST}/#{AWS_BUCKET}/#{self.flash_name}" end # transcode file def transcode begin RVideo::Transcoder.logger = logger file = RVideo::Inspector.new(:file => self.asset.path) command = "ffmpeg -i $input_file$ -y -s $resolution$ -ar 44100 -b 64k -r 15 -sameq $output_file$" options = { :input_file => "#{RAILS_ROOT}/#{self.asset.path}", :output_file => "#{RAILS_ROOT}/#{self.flash_path}", :resolution => "320x200" } transcoder = RVideo::Transcoder.new transcoder.execute(command, options) rescue RVideo::TranscoderError => e logger.error "Encountered error transcoding #{self.asset.path}" logger.error e.message end end The input file is added to the asset directory, but I never get an outputted file. On the view page aasm hangs on "converting".

    Read the article

  • Do Ruby/Rails state machines exist that execute event transitions when a state change occurs?

    - by Bryan
    Hello All, Hopefully this isn't a silly question and I'm just not overlooking something in Ruby/Rails state machines (AASM, Transitions, AlterEgo, etc). From what I can tell, these state machine implementations operate on the preface that an event will get fired and the appropriate transition for that event will be triggered based on the old and new state. However, they don't seem to work the other way; say a user wants to change state from 'created' to 'assigned' and have the correct transition occur (rather than firing the event that causes the current state to be transitioned to the new state). Essentially, I want the user to be able to select a new state from a select box of available states and have the appropriate transition, guards, success callbacks, etc executed. Does anyone know if the existing state machine implementations support this?

    Read the article

  • Dynamic State Machine in Ruby? Do State Machines Have to be Classes?

    - by viatropos
    Question is, are state machines always defined statically (on classes)? Or is there a way for me to have it so each instance of the class with has it's own set of states? I'm checking out Stonepath for implementing a Task Engine. I don't really see the distinction between "states" and "tasks" in there, so I'm thinking I could just map a Task directly to a state. This would allow me to be able to define task-lists (or workflows) dynamically, without having to do things like: aasm_event :evaluate do transitions :to => :in_evaluation, :from => :pending end aasm_event :accept do transitions :to => :accepted, :from => :pending end aasm_event :reject do transitions :to => :rejected, :from => :pending end Instead, a WorkItem (the main workflow/task manager model), would just have many tasks. Then the tasks would work like states, so I could do something like this: aasm_initial_state :initial tasks.each do |task| aasm_state task.name.to_sym end previous_state = nil tasks.each do |tasks| aasm_event task.name.to_sym do transitions :to => "#{task.name}_phase".to_sym, :from => previous_state ? "#{task.name}_phase" : "initial" end previous_state = state end However, I can't do that with the aasm gem because those methods (aasm_state and aasm_event) are class methods, so every instance of the class with that state machine has the same states. I want it so a "WorkItem" or "TaskList" dynmically creates a sequence of states and transitions based on the tasks it has. This would allow me to dynamically define workflows and just have states map to tasks. Are state machines ever used like this?

    Read the article

  • Load Ruby on Rails models without loading the entire framework

    - by epochwolf
    I'm looking to create a custom daemon that will run various database tasks such as delaying mailings and user notifications (each notice is a separate row in the notifications table). I don't want to use script/runner or rake to do these tasks because it is possible that some of the tasks only require the create of one or two database rows or thousands of rows depending on the task. I don't want the overhead of launching a ruby process or loading the entire rails framework for each operation. I plan to keep this daemon in memory full time. To create this daemon I would like to use my models from my ruby on rails application. I have a number of rails plugins such as acts_as_tree and AASM that I will need loaded if I where to use the models. Some of the plugins I need to load are custom hacks on ActiveRecord::Base that I've created. (I am willing to accept removing or recoding some of the plugins if they need components from other parts of rails.) My questions are Is this a good idea? And - Is this possible to do in a way that doesn't have me manually including each file in my models and plugins? If not a good idea What is a good alternative? (I am not apposed to doing writing my own SQL queries but I would have to add database constraints and a separate user for the daemon to prevent any stupid accidents. Given my lack of familiarity with configuring a database, I would like to use active record as a crutch.)

    Read the article

  • Having trouble getting cucumber 6.3 to run on rails 2.3.4

    - by Yak
    Hi, I am trying to to get cucumber to run with no luck. Here is the error I am seeing: cucumber features Using the default profile... no such file to load -- test/ (MissingSourceFile) /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in polyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.3.0/lib/polyglot.rb:65:in require' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in require' /Users/yakovrabinovich/Starstreet/starstreet/vendor/gems/cucumber-0.6.3/bin/../lib/cucumber/rails/world.rb:11 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in polyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.3.0/lib/polyglot.rb:65:in require' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in require' /Library/Ruby/Gems/1.8/gems/cucumber-rails-0.3.0/lib/cucumber/rails/rspec.rb:1 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in polyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.3.0/lib/polyglot.rb:65:in require' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in require' /Users/yakovrabinovich/Starstreet/starstreet/features/support/env.rb:11 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in polyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.3.0/lib/polyglot.rb:65:in require' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/rb_support/rb_language.rb:124:in load_code_file' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:85:in load_code_file' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:77:in load_code_files' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:76:in each' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:76:in load_code_files' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/cli/main.rb:48:in execute!' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/cli/main.rb:20:in execute' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/cucumber:8 /usr/bin/cucumber:19:in `load' /usr/bin/cucumber:19 Here are my gems: Yakov-Rabinovichs-MacBook:1.8 yakovrabinovich$ gem list * LOCAL GEMS * aasm (2.1.3) acl9 (0.11.0) actionmailer (2.3.4, 2.2.2, 1.3.6) actionpack (2.3.4, 2.2.2, 1.13.6) actionwebservice (1.2.6) activerecord (2.3.4, 2.2.2, 1.15.6) activeresource (2.3.4, 2.2.2) activesupport (2.3.4, 2.2.2, 1.4.4) acts_as_ferret (0.4.3) authlogic (2.1.3) bgetting-hominid (1.2.0) builder (2.1.2) capistrano (2.5.2) capistrano-ext (1.2.1) cgi_multipart_eof_fix (2.5.0) chronic (0.2.3) columnize (0.3.1) configatron (2.5.1) cucumber (0.6.3) cucumber-rails (0.3.0) daemons (1.0.10) database_cleaner (0.5.0) diff-lcs (1.1.2) dnssd (0.6.0) factory_girl (1.2.3) fastthread (1.0.1) fcgi (0.8.7) ferret (0.11.6) gem_plugin (0.2.3) gemcutter (0.4.1) highline (1.5.0) hoe (2.5.0) hominid (2.1.0) hpricot (0.6.164) json (1.2.0) json_pure (1.2.0) libxml-ruby (1.1.2) linecache (0.43) mocha (0.9.8) mongrel (1.1.5) needle (1.3.0) net-scp (1.0.1) net-sftp (2.0.1, 1.1.1) net-ssh (2.0.16, 2.0.4, 1.1.4) net-ssh-gateway (1.0.0) nokogiri (1.4.1) oauth (0.3.6) pg (0.8.0) polyglot (0.3.0) rack (1.0.1) rack-test (0.5.3) rails (2.3.4, 2.2.2, 1.2.6) rake (0.8.7, 0.8.3) RedCloth (4.1.1) rspec (1.3.0) rspec-rails (1.3.2) ruby-debug (0.10.3) ruby-debug-base (0.10.3) ruby-hmac (0.4.0) ruby-openid (2.1.2) ruby-yadis (0.3.4) rubyforge (2.0.3) rubygems-update (1.3.5) rubynode (0.1.5) sqlite3-ruby (1.2.4) term-ansicolor (1.0.4) termios (0.9.4) test-unit (1.2.3) thoughtbot-factory_girl (1.2.2) thoughtbot-shoulda (2.10.2) treetop (1.4.4) whenever (0.4.1) will_paginate (2.3.11) xmpp4r (0.4) yamler (0.1.0) Any help would be greatly appreciated!

    Read the article

1