Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Building Social Features in Ruby on Rails Adding State Accepting Friendships

Seph Cordovano
Seph Cordovano
17,400 Points

Receiving error due to outdated gem no longer being updated. How to proceed in this series?

With the state_machine gem not being updated anymore, what can those of do who are using newer versions of rails? Aside from scrapping our project and starting over with the versions matching those in these videos (I'm not even sure what versions are being used) since I'm using this to integrate friendships into an already existing project of mine.

I keep getting this in the rails console if I even attempt to touch the UserFriendship table. NoMethodError: undefined method `state_machine'

And if I do anything involving the friendship relationships in the app I get similar errors. undefined method `state_machine' for #<Class:0x007fed6aaab810>

Jason Seifer, any input?! Viva la Treehouse!

4 Answers

Seph Cordovano
Seph Cordovano
17,400 Points

I actually went that route yesterday Maciej Czuchnowski but I can't seem to figure out how the syntax transfers over completely, especially in the user_friendship model. Did you complete this course with AASM? If so, would you mind showing what your user_friendship model and controller looks like?

Zach Ford
Zach Ford
63 Points

Maciej Czuchnowski after having the same error with state_machine I switched to aasm. I keep getting an "uninitialized constant UserFriendship::AASM" After "include AASM" on my user friendship.rb - Everything is spelled correctly - Any clues?

Ben Wong
Ben Wong
2,652 Points

/Users/benwong/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.4/lib/active_support/core_ext/hash/keys.rb:75:in `block in assert_valid_keys': Unknown key: :conditions. Valid keys are: :class_name, :anonymous_class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache, :join_table, :foreign_type (ArgumentError)

I got this error. Does it have to do with the fact that State Machine is not being supported for Rails 4?

Thanks,

Ben

Ben Wong
Ben Wong
2,652 Points

Alright. Codes used in the video like "sources", and "conditions" are the culprit because State Machine is not supported in Rails 4.

Ben Wong how did you solve it?