hi folks.
i want to check if a param exists if not to set it to a default value
for my date range filter. in my controller i have:
@from_date = Date.strptime(params[:startdate],"%d/%m/%Y")
@to_date = Date.strptime(params[:enddate],"%d/%m/%Y")
@articles = @results.find(:all,
:conditions => [ "created_at >= ? and
created_at <=?",@from_date,@to_date],
:order => 'created_at desc', :page => {:size
=> 5, :current => params[:page]})
this works as long as i have the params in the query string in the
address. but if i remmove them i want to be able to default to a date
range from today back a couple of months.
is there a param[:startdate].exists? check i can do???
any help asap would be great!!
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---