i've 2 methods one for posts and another for users...
i'd like to get number of users for every month and same for number of
posts for every month..
for that i had written like
@januser=User.find(:all,:condition=>["created_at between
? AND ?","#{changedyear}-01-01","#{changedyear}-01-31"])
like this for every month as i don't 've a feild name month in
database....
and the same query can be used by post like
@janpost=Post.find(:all,:condition=>["created_at between ? AND
?","#{changedyear}-01-01","#{changedyear}-01-31"])
and changedyear is a dynamic one...........
so the query is same for both of them...
so can i write
@jan+"#{name}"="#{Name}".find(:all,:condition=>["created_at between ?
AND ?","#{changedyear}-01-01","#{changedyear}-01-31"]) where name may be
post or user ....
Well I thin you're looking for instance_variable_set and constantize,
but personally I'd put most of that method in the post/user model (and
probably return a hash keyed by the month you're looking at).
The finder methods generated by ActiveRecord take a range (I think), so you can find the start date for January and then the end date and do something like this: