Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

chris salvi
chris salvi
7,584 Points

Can someone explain this terminal error to me?

I get the following when trying to run my rails server:

/Users/salvi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/core_ext/hash/keys.rb:71:in `block in assert_valid_keys': Unknown key: :conditions. Valid keys are: :class_name, :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 (ArgumentError)


Not even sure where to start....

Matt West

https://github.com/donsalvadori

4 Answers

Matt West
Matt West
14,545 Points

Hi Chris,

I've been through your code and fixed-up a few syntax issues. Take a look at the diffs in this pull request and let me know if you're not sure about anything. https://github.com/donsalvadori/treebook/pull/4

:)

chris salvi
chris salvi
7,584 Points

Matt West

I almost feel guilty because your selfless assistance would cost like $100/hr here in the usa, but thank you so much. I do have some questions about the altering of some of my tests, but I would rather email you via your email on github. Is that ok?

Also, how did you manage to read the terminal error and get to where you did with the corrections? I am getting better at decrypting the outputs on the terminal, but this one threw me for a loop!

Matt West
Matt West
14,545 Points

Feel free to comment on the code on Github. If you view the commit at the link below, you can click the line number next to the piece of code you want to discuss and leave an inline comment.

Best to keep it public so that anyone else that's curious can see :)

RE: Debugging I started with a Google search which helped fix the original issue. The subsequent errors included a filename & line number so were easier to debug.

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Chris,

This thread might lead you in the right direction. https://teamtreehouse.com/forum/unknown-key-conditions.

I hope this helps.

chris salvi
chris salvi
7,584 Points

Justin Horner

That didnt fix my problem. The terminal now reads like so:

/Users/salvi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/core_ext/hash/keys.rb:71:in `block in assert_valid_keys': Unknown key: :conditions. Valid keys are: :class_name, :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 (ArgumentError)
chris salvi
chris salvi
7,584 Points

here is my user.rb for reference

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

         validates :first_name, presence: true

         validates :last_name, presence: true

         validates :profile_name, presence: true,
                    uniqueness: true, 
                        format: {
                            with: /\A[a-zA-Z0-9_-]+\z/,
                            message: 'Must be formatted correctly'
                        }

         has_many :statuses
         has_many :user_friendships
         has_many :friends, -> { where(user_friendships: { state: "accepted"}) }, through: :user_friendships


         has_many :pending_user_friendships, class_name: "userFriendship",
                                                foreign_key: :user_id,
                                                conditions: { state: 'pending'}

         has_many :pending_friends, trough: :pending_user_friendships, source: :friend

         def full_name
             self.first_name + " " + self.last_name
         end

         def to_param
            profile_name
         end

         def gravatar_url
            stripped_email = email.strip
            downcased_email = stripped_email.downcase
            hash = Digest::MD5.hexdigest(downcased_email)

            "http://gravatar.com/avatar/#{hash}"
         end
end
Brandon Barrette
Brandon Barrette
20,485 Points
has_many :pending_friends, trough:  :pending_user_friendships, source: :friend

Should read through and not trough

chris salvi
chris salvi
7,584 Points

thanks for the catch, but Im still getting the same error :/

I think it has something to do with me using has many conditions

In the terminal it says that "Unknown key: :conditions"

Any tips on how I can make this correct? I'm assuming this is some new feature of Rails 4

** This is really becoming a fatal error as it prohibits me to installing new gems in my file, thus putting a firm stop on my progress on the project :(

chris salvi
chris salvi
7,584 Points

well I think you're the man and the most selfless coder Ive met on my journey to learning RoR.

I would like to share my ruby tapas subscription with you when I order it next month. I will give you the information if you so desire in your private email.

Matt West
Matt West
14,545 Points

Just happy to help :)

chris salvi
chris salvi
7,584 Points

a rare trait in this day and age, selfless help.

I'll still send you my ruby tapas sign in info as a thanks for being such a great coding mate along the way. It's the least I can do. The videos are suppose to be top notch, and unlike Railscast they still update them!