On 15 October 2015 at 22:57, Noctua Studio
<[email protected]> wrote:
> hi to everybody ! :-) before ask something I prefer to say sorry for may bad 
> english and sorry because I'm a junior developer of rails, in last 3 days 
> I've tried to visualize some statistics in rails but I found a lot of problem 
> somebody can help me ? I leave my DB struct if someone have some good idea
>
> THIS IS WHAT I TRY TO DO: I've tried to visualize some data in a table for 
> know how many event I've all day, and visualize: TOTAL PRICE, TOTAL_EVENT, 
> TOTAL_PAX every day, if you see the DB table you can see I use a date range 
> for every Event, and there I become to get MAD ! in the DB every event ha the 
> struct
>
> event  price pax  room_numer start_date      end_date
> 1          2        2     1                   10-10-2015  12-10-2015
> 2          3       12    2                   8-10-2015    18-10-2015
> 3          2        20   3                   12-10-2015  17-10-2015
>
> AND this is what I want visualize
>
> data        total_event      total_price     total_pax
> 08/10        1                     2                    12
> 09/10        1                     2                    12
> ...
> 18/10        1                     2                    12
> 19/10        0                     0                    0
>
> for made that I need to use a model because I've 3 view... week / month / 
> year and I think is better use one Method ? right ?

No you don't need another model.  Models relate to objects not views.
Most likely this would be be handled by the events controller by a
dedicated action with url parameters to specify date range and whether
it week/month/year.

The first thing to do is probably to write Event scopes to provide all
the events relevant to a particular day week or year.  Look at the
Rails Guides on ActiveRecord Queries if you don't know how to do that.
Make sure you provide tests in your automated tests to check it works.
When that is going come back if you can't see where to go from there.

Colin

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv88BDb0ypt_kpg21PfmEfLoRyHJ6zDzQQ2vUE6Xs9cQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to