Ruby on Rails Friday, August 30, 2013

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

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b52648e4fee98de31e2c994f7aed110d%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment