Hi Chaps,
Having a little issue with my date filter business here, ive got a
date_filter (something i added to my form builder - which works by the
way) in my page, and I want to use it to filter my @articles.
in my page.....
<% form_for @date_filter do |f| %>
<%= f.date_field :before %>
<%= f.date_field :after %>
<% end %>
in my ruby class...
class DateFilter
attr_accessor :before, :after
def initialize(attributes)
attributes.each { |k,v| self.send("#{k}=", v) }
end
end
and in my controller...
@date_filter = DateFilter.new(params[:date_filter])
@articles = @results.find(:all,
:conditions => [ "created_at >= ? and
created_at <=?", @filter.before, @filter.after],
:order => ''created_at
desc'', :page =>
{:size => 5, :current => params[:page]})
but I am receiving the following error...
ActionView::TemplateError (Called id for nil, which would mistakenly be
4 -- if you really wanted the id of nil, use object_id) on line #24 of
admin/articles/index.html.erb:
21: <h3>Filter by: Date</h3>
22: Between <br/>
23:
24: <% form_for @date_filter do |f| %>
25: <%= f.date_field :before %>
26: <%= f.date_field :after %>
27: <% end %>
Perhaps someone could help me to see whats going wrong...
Many thanks in advance
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---