Flowdock

Notes posted by ishka

RSS feed
March 4, 2010
1 thank

AASM named scopes

If you are using the aasm plugin/gem, this will generate all named scopes for your various states.

Code example

Class Article <  ActiveRecord::Base

  include AASM

  aasm_initial_state :created

  aasm_state :published
  aasm_state :unpublished
  aasm_state :deleted
  aasm_state :created

  aasm_event :publish do
    transitions :to => :published, :from => [:created]
  end

  aasm_event :unpublish do
    transitions :to => :unpublished, :from => [:created, :published]
  end

  aasm_event :delete do
    transitions :to => :deleted, :from => [:published, :unpublished]
  end

  aasm_states.each { |s| named_scope s, :conditions => { :state => s.to_s } }  

end
December 28, 2008
1 thank

i think that's a bit better resourceful approach...

Code example

auto_discovery_link_tag :atom, formatted_movies_url(:atom), :title=>'New movies'
October 10, 2008
2 thanks

Make an action onchange

collection_select(nil, :provincia_id, @provincias, :id, :nombre, {:prompt => “Seleccione una provincia”}, {:onchange => “#{remote_function(:url => {:controller => ‘direccions’, :action => ”update_pueblos“}, :with => ”‘provincia_id=’+value“)}”})