Date_select and ActiveRecord find()

If I pass a date through date_select to a controller, can a Active
Record object be found based on this date that is passed? Here is
what my log says:

ArgumentError (Unknown key(s): publication_date(2i),
publication_date(3i), publication_date(1i)):
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/hash/keys.rb:48:in
assert_valid_keys' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/base.rb:1323:invalidate_find_options’
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/base.rb:376:in
find' /app/controllers/admin/publication_volume_controller.rb:21:innew’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:910:in
perform_action_without_filters' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:368:inperform_action_without_benchmark’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /opt/local/lib/ruby/1.8/benchmark.rb:293:inmeasure’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/rescue.rb:82:inperform_action’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:381:in
process_without_filters' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:377:inprocess_without_session_management_support’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:117:in
process' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:indispatch’
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/fcgi_handler.rb:150:in
process_request' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/fcgi_handler.rb:54:inprocess!’
/opt/local/lib/ruby/vendor_ruby/1.8/fcgi.rb:600:in each_cgi' /opt/local/lib/ruby/vendor_ruby/1.8/fcgi.rb:597:ineach_cgi’
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/fcgi_handler.rb:53:in
process!' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/fcgi_handler.rb:23:inprocess!’
/Users/smtlaissezfaire/Sites/rails/miningstocks/public/dispatch.fcgi:24
Rendering
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/templates/rescues/layout.rhtml
(500 Internal Error)

Does this mean that I will have to drop down to select_date? Do only
the methods new, create, and update_attributes work with date_select
on a AR object?

Thanks for all the help,

Scott T.

After much frustration, I found the solution to my own problem. The way
to do it seems to be to use date_select, then parse the params in a
method in application.rb:

class ApplicationController < ActionController::Base
def convert_date_from_params
Date.new(params[:date][:year].to_i, params[:date][:month].to_i,
params[:date][:day].to_i)
end
end

If anyone else has a better solution, I’d love to hear it.

Best,

Scott T.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs