Hi all, first post! I have a question regarding where to start with a
particular app I'm building. Hoping someone can set me on the right
path. The scenario is pretty straight forward.
This is the hierarchy of info:
Each state has many Towns
Each town has the following pages
Part of my issue, due to lack of experience, is really where to start.
My main confusion is how to associate the pages to correlate with each
state and town and how I would build the main navigation. The routing
and url structure I would like is
www.example.com/state/town/profile/geography. I have gone through many
of the normal tutorials, but I can seem to get a breakthrough mentally
Very first place I always start is "What problem does this solve for whom?" and then start to ask "What tasks do they need to do? What problems do they have in performing those tasks? How can I make something that will help them do what they need to do?" Write user-centered stories of use cases. These become your early acceptance tests. When you have all that, the tasks and stories should lead to a navigation structure that will make sense to the user.
If you think you have all this information already, present it here and give us something to go on. Right now, you just have a collection of models, and we don't have a clue why.
@tamouse_m, thank for your insight. Those are great questions and I'll
be sure to note them. So here are the best answers I have. In this
particular situation, users are visiting static pages of information.
There are no real dynamic tasks involved, just browsing pages and
In this case, a user will visit www.example.com. This root page lists
all states included in the database. The user will click on a state, and
that page will list all the towns, within that state, that are in the
database. Next the user clicks a specific town link. On this particular
page, there is a main navigation with each of the pages I originally
listed in a navbar. Profiles has three subpages. In each of these pages,
there is static HTML, that differs for each town, for viewing purposes
only. So it's fair to assume that these pages and subpages exist for
each town. Nothing dynamic. On top of this, I would like a simple admin
are where I can add new states, pages, and information to the
pages/subpages as well.
This is easily handled by something like WordPress, because it's a
simple CMS tool. However, I want to use this particular example to learn
more about RoR. Hopefully I've clearly stated the tasks involved in the
That all looks ok, so what is the question that you are asking?
I presume you have already worked right through a good tutorial on
rails, such as railstutorial.org, which is free to use online. If not
then do so and you will understand the basics of Rails.
I guess I just need to wrap my head around associations. That's what
I've been reading more about and it seems like it's taking me down the
right path. What I'm still confused about, is how to separate the admin
side from the user side. I know there are gems for this, but I want to
understand the logic behind the way it works.
I think when you say "static" html for the pages, you really want
dynamically generated content. You need a simple template which presents
the requested information with links up and down the chain.
The first thing you need to do, particularly if you have data to start
off with, is sort out the database structure.
Once you've got your database links mapped, you know the page order as
well: You start with an index which may or may not contain a search
The index contains, for example, rows of dynamically generated data and
links. In this case, States. Each state links to another template
populated with dynamically generated content: towns.
Once you plan the Model, the View should be obvious. After that you just
need to start with the default view (index) in the Controller, and then
you can let the database links guide your way through the different
What I'd suggest in the latter case is a good long look at active_admin; not necessarily to use, as you say, but to understand how one implements such a thing. After you've perused it, you might decide it's okay to use, or roll your own (as you say this is primarily a learning project).
I'm still unclear *why* a user would be browsing these pages. What information are they looking for? What question does this information answer for them? What sorts of things will they be able to do once they have this info?
The steps you list are necessary to outline, for sure, but why do you want/need to put your user through them to get at the information they are seeking? That is the important question to answer early, I think. If you think about it, drilling down can be a very slow exercise for users, especially if they have a slow network connection and have to wait for page loads, etc., even if your app is serving up largely static data. Think about how your user is going to see this and get right down the bone on what they need to see, and not put operations in their way if not needed. I think, perhaps, you've spent quite a bit of time thinking about how to organize the data, which is a good thing, really, but not necessarily enough time yet thinking about how the user would be best served in accessing it, which can be completely different than how it's persisted in the backend.