Form woes

I have a form which generates a report. The first issue I ran into was
trying to create a model to validate some of the entries without saving
them…that didnt’ work out too well, so I created a report table. I
figured uses could save reports for later viewing as a feature.

The form has two field names: report for fields pertaining to the
report and :check which are fields not being saved. The check fields
have names like: “use_agreed_to_participate” which let me know to use
the data in that field to filter by. Here’s a snippet:

Schedule Date


<%= datetime_select('report', 'schedule_date_to') %><br /><br />


<%= datetime_select('report', 'schedule_date_from') %>
<%= check_box('check','use_schedule_date', :checked_value => "1",

:unchecked_value => “0”) %>

Everything works perfect unless my Report object throws an error on
save which brings you back to the form page.

Error snippet:

Showing app/views/admin/_report_form.rhtml where line #31 raised:

undefined method `use_updated_on’ for

Extracted source (around line #31):

28: <%= datetime_select(‘report’, ‘updated_on_to’) %>

31: <%= check_box(‘check’,‘use_updated_on’, :checked_value => “1”,
:unchecked_value => “0”) %>


The trace:
send' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_helper.rb:333:invalue’
to_check_box_tag' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_helper.rb:208:incheck_box’
_run_rhtml_admin__report_form' #{RAILS_ROOT}/app/views/admin/report.rhtml:7:in_run_rhtml_admin_report’
#{RAILS_ROOT}/app/controllers/admin_controller.rb:39:in `new_report’

And finally, liine #39 in new_report:

35 @report =

36 if

37 redirect_to :action => :show_report, :id => @report[:id]

38 else

39 render :action => ‘report’

40 end

I know I’m probably missing something simple here and it has something
to do with use_updated_on (and friends) not having a model backend…but
is there an elegant way to fix this without hacking rails source or
some such?

As usual, as soon as I take the time to submit to list I find the
answer. So I’ll answer it here:

Please look into attr_accessor setting for your model.


I am having the same problem, except with radio buttons, and I don’t
understand how you solved it with an attr_accessor. Could you explain
a bit more in depth?


Actually I also figured it out right after I sent the email… and
truly all I needed was the attr_accessor… so thanks!

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