Friday, May 28, 2010

[Rails] Re: Display only by date selected

Matt Royer wrote:
> I have the following code:
>
> ----
>
> <h3>Today's Activity</h3>
> <hr>
>
> <div id="order">
> <% @orders.reverse.each do |order| %>
> <%= link_to_remote( "#{order.id} &nbsp &nbsp &nbsp #{order.name}" ,
> :url => {:controller => 'orders', :action => 'show', :id => order.id },
> :update => "order_div", :method => 'get' ) %>
>
> <% end %>
> </div>
>
> ----
>
> This code works great. Does exactly what I need. I'm displaying the
> order id and customer name on the order. I have the newest one on top by
> using the reverse method.
>
> What I need to be able to do is where it has "Today's" in the h3 tag, I
> want to created a dropdown that people can select: Today, Yesterday, One
> Week, 2 Weeks, One Month, All, etc.
>
> I don't know what kind of logic I'll need to make sure that the only
> orders showing are those connected to one of those actions in the
> dropdown list. Only that I'll need to call the create date field in the
> db.
>
> I've gone through a few ruby on rails books and a ruby book. This is the
> my first personal project that I've worked on, so I'm not sure how to
> complete this. Any help would be appreciated.

Seems like pretty elementary logic...
For populating the droplist on the form, you just need a set of items
with a defined coding scheme (0 = today, 1 = 1 week, 2 = 2 weeks, 3 = 1
month, 4 = 1 year, 5 = all, or some such).

In the controller interpreting the link_to_remote, it just had to
determine:
What's today?
That tells you the range for yesterday
That tells you the range for today through today - 6 days
That tells you the range for today through today - 13 days
etc
etc

Peruse the Pickaxe book... you *do* have one don't you? If not, for
shame...
(just joking, you should be able to find the appropriate ruby references
on the web).
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate