Hello everyone. I’m currently building a blog in Rails 4 to serve news from
the local soccer league in my country. The news part has been a breeze but
I have not been able to code the fixtures and result portion.
I have been totally stumped as i don’t even have an idea on how best to go
about this. To make matters worse, I have to associate these
fixtures/results to their respective pre-match previews and post-match
reviews(I intend to make these normal post entries with a category).
Please, I might not necessarily need actual codes. Pseudo codes would
suffice.
Thanks.
PS: If you need more info about how i have the app setup, just ask. Thanks
in advance.
On Mon, Jan 13, 2014 at 6:44 PM, Thompson E. [email protected]wrote:
suffice.
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/f4e9cea4-a870-47b7-901e-9a416db04234%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.
Are you talking about test fixtures here? Or something else? Test fixtures
are YAML files that load data into your database for testing.
I’m also lso quite unclear what you mean to produce for results. It’s too
generic a term. Do you mean match results? Displaying those seems like it
would be rather straight forward; the difficult thing would be obtaining
the data, unless you plan to enter it by hand from some other place.
Thanks for replying. I’m not really sure I know what a “Test
fixture” is though. This is what I’m trying to do. The soccer league in
my
country doesn’t have any true sites like ESPN Soccernet.com. I am trying
to
replicate that.
I have a fixture model, it has a home_team column and an away_team
column.
These columns are supposed to be foreign keys to a Team model, I don’t
know
how to set that up.
Then I have a scheduled_at column and a played column that is a Boolean.
I’d like a scenario where the fixtures/index shows all the matches for
the
present week with a calendar to browse future and past fixtures.
Hopefully this would make my previous post a bit clearer.
Thanks
On Tue, Jan 14, 2014 at 2:52 AM, Thompson E. [email protected]
wrote:
like a scenario where the fixtures/index shows all the matches for the
present week with a calendar to browse future and past fixtures.
Everything you said pretty much confused me until I sat down and
thought about how I would design the app based on what you described
was happening and this is what I came up with:
https://gist.github.com/envygeeks/8416079 even if it’s not right it
should get you started off hopefully, you can find more information
about what all that is here:
Active Record Associations — Ruby on Rails Guides
To the gist, I’d add home_goals and away_goals columns to the Game
model,
given the nature of the beautiful game. Your Post model would include
“belongs_to :game”, and on the other side the Game would have “has_many
:posts”. You’d then add a game_id column to the Posts table using a
migration.
Don’t worry about having separate relationships for previews and reports
on
that one, as presumably the fact that reports will go up after the game,
and previews before it, will sort things out (besides which: what about
post-match interviews, tactical analysis, injury lists etc, which might
all
be attached to a game without really being one or the other? You may
want
this kind of content later on, even if you don’t to begin with).
In general, don’t necessarily worry about getting everything in your
models
right up front. Football may be a matter of 22 blokes kicking a pig’s
bladder around, but there’s a lot of info to keep track of these days
(in
England at least, we seem to have contracted the sports statistics
addiction from the Americans). It’s easy enough to add a column here and
there with a migration. Write some basic controllers/views for doing
CRUD
operations on your core models, get the basic relationships in place and
into the browser, and iterate from there.
On Tuesday, January 14, 2014 8:52:20 AM UTC, Thompson E. wrote:
Thanks for replying. I’m not really sure I know what a “Test
fixture” is though. This is what I’m trying to do. The soccer league in my
country doesn’t have any true sites like ESPN Soccernet.com. I am trying to
replicate that.
Some terminology mixup here - Tamouse is referring to a facility rails
provides for setting up data for your automated tests (“text fixtures”)
whereas I believe you are using fixture in the sense of the set of games
that are to be played over a season.
I have a fixture model, it has a home_team column and an away_team column.
These columns are supposed to be foreign keys to a Team model, I don’t know
how to set that up.
If you do
belongs_to :home_team, :class_name => ‘Team’
belongs_to :away_team, :class_name => ‘Team’
Then rails will assume the presence of home_team_id and away_team_id
columns and will assume that they are pointing at the id column from the
Team model.
It sounds like your post model would also need an (optional) fixture_id
column that would record that is discussing that particular fixture
Fred
Then I have a scheduled_at column and a played column that is a Boolean.
Also: add a date to your Game model, like so:
class AddMatchDate < ActiveRecord::Migration
def change
add_column :games, :match_date, :date
end
end
Forget a ‘played’ boolean: 99 times out of 100, the game will be played
if
that date’s in the past: if it’s abandoned or postponed, change the
date!
On Tue, Jan 14, 2014 at 10:44 AM, James Turley <
Thanks guys, now I am truly excited about this project again. I’ll keep
you
posted on my progress.
Thanks Fred, that’s got the wheels in my head ticking again. I’ll start
coding and if I do need anything else I’ll post it here.
On Jan 14, 2014 11:10 AM, “Frederick C.”
[email protected]
Hi guys, coding has been quite good and I’ve been able to put together a
nice app(I’d deploy to heroku soon). I’ve kinda hit a snag(again?!). As
you
would now know, I’m building a Soccer blog/app and I would like your
take
on how you’d implement the following scenario.
I’m trying to query the Game model for games per week with the current
week
in focus and pagination to previous weeks for past games and future
weeks
for upcoming games. By the way I added a postponed Boolean to the Game
model to handle games that have been called off.
Thanks guys.