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 trialchris salvi
7,584 PointsCan 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....
4 Answers
Matt West
14,545 PointsHi 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
:)
Justin Horner
Treehouse Guest TeacherHello Chris,
This thread might lead you in the right direction. https://teamtreehouse.com/forum/unknown-key-conditions.
I hope this helps.
chris salvi
7,584 PointsThat 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
7,584 Pointshere 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
20,485 Pointshas_many :pending_friends, trough: :pending_user_friendships, source: :friend
Should read through and not trough
chris salvi
7,584 Pointsthanks 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
7,584 Pointswell 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
14,545 PointsJust happy to help :)
chris salvi
7,584 Pointsa 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!
chris salvi
7,584 Pointschris salvi
7,584 PointsMatt 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
14,545 PointsMatt West
14,545 PointsFeel 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.