SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    976
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    question about argumentError

    I'm getting this from an update function that i had working and then i started working on another section of the site and for some reason this is broken now, but i don't understand the error

    ArgumentError in EmploymentController#update_job_description

    Unknown key(s): title, duties, pay_band_id, description, department_id, requirements, exempt

    now the unknown keys are form fields with corresponding database columns... but how to i find out what's happening here? i have yet to acquire enough experience with this framework to be able to reliably read the application trace AND know what it means.

    Can anyone here help or point me in the right direction? my controller action:
    Code Ruby:
      def update_job_description
        @job_description = JobDescription.find(params[:job_description])
        if @job_description.update_attributes(params[:job_description])
          redirect_to '/employment/list_job_descriptions'
          flash[:notice] = "job description updated"
        else
          redirect_to :action => '/employment/edit_job_description', :id => @job_description
          flash[:notice] = "job description update failed"
        end
      end
    your brain reacts in the same way whether you are
    looking at something or thinking about it...

  2. #2
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    976
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow... nothing?

    apparently it's getting hung up here:
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/hash/keys.rb:47:in `assert_valid_keys'

    and i've read up about assert_valid_keys, the only thing i can find is that maybe my keys are getting turned into strings, i mean is rails thinking that ("page"=>{"content"=>) is two strings? why/how is this happening? i'm not doing it... can't be MY fault. ... can it?
    your brain reacts in the same way whether you are
    looking at something or thinking about it...

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    I am still very new to Rails, so I may not be much help. I too have trouble harvesting useful information from traces, although once in a while I spot something among the mess that helps point me in the right direction.

    I find it much easier to debug by using
    rake test:units
    rake test:functionals
    rake test:integration
    Have you tried them? IMHO, the information is much more helpful.

    Another place to look is in the logs. Almost as bewildering as the traces, but they usually contain more hints in them (parameters, sql queries, rendering, etc.)

    EDIT: This may be of help. I installed the "ruby-debug" gem and checked it out a bit. It lets you step through the code, set breakpoints, and inspect values through the console. My prior bebugging experience consists mainly of using echo() and alert() (PHP and javascript) so it's a bit overwhelming to me at present, but if you have experience with this kind of tool you may like it. It can be integrated with the TextMate editor too if you're used to using that.

  4. #4
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm certainly no Rails expert, but shouldn't:

    Code Ruby:
    @job_description = JobDescription.find(params[:job_description])

    Be replaced with:

    Code Ruby:
    @job_description = JobDescription.find(params[:id])

    In your original I think you're trying to find an existing job description using the updated values that have just been submitted.

  5. #5
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    976
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup... you're right... i shoulda replied to this post.

    needless to say i took a whip to myself after realizing that mistake. DUH!

    thanks for the reply!
    your brain reacts in the same way whether you are
    looking at something or thinking about it...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •