I have a scenario where I need to retrieve an array of specific
attributes from a table. I have a TransportAttendanceBlock table. In the
table I have blocked(boolean) and blocked_date attributes. From a
controller I am fetching this table by passing params of date and
boolean value.
Controller code:
@blocked_date =
TransportAttendanceBlock.by_blocked_date_and_blocked(@today,1)
Model
named_scope :by_blocked_date_and_blocked, lambda{|date,status|
{:conditions=>
{:blocked_date=>date.beginning_of_month…date.end_of_month,
:blocked=>status}}}
Here in the controller I am getting the entire objects of
TransportAttendanceBlock table.
But I need to just pass any array of dates only in the @blocked_date
variable as json.
So how do I extract only blocked_date attributes and assign it to
@blocked_date variable. Please help. I am using rails2.3 and ruby 1.8.7