Making a New Site

Hi,
I'm kind of new to Ruby on Rails, I've been slowly learning it for a
while now, and think I am ready to further my learning, by actually
attempting to make a site. I've already made a site and styled it, I
only need to now include the code behind it. I figure there is only so
much you can learn, before you actually start to put it in practice,
and once I start to code this site, I'll learn things on the way. I
heard ruby has one of the greatest and strongest communities
surrounding it, so I look forward to your guys help.

Before, I make this site though, I don't know where to get started.
The site will be a game site, and I'd hoped to just load all of the
flash swf's into a folder, then use controllers to call each one. I
plan on having tons of game though, so is there an easier way to
generate urls for them, and creating an index page that will list
games? Could I create a database that includes columns such as path
to .swf, title, description, and genre? Then automatically call them,
when the user types in a path.

For example,
- the user types in the address http://site.com/games/billysadventure
or clicks on a automatically generated link
-Ruby on Rails then knows to look for the entry billysadventure in the
database
-Ruby takes the rest of the info for the entry and displays it in it's
correct locations on the page

If this is really complex, I don't expect you to write out specific
instructions, but if it's reasonable, that would be really, really
nice. Otherwise, could you at least point me in necessary directions,
so I can find out the way to do everything. Thanks for all or any help
or comments.
Let me know if I am unclear, and I'll restate it.
Thanks again,
Connor

I'm sorry if I was unclear, or am I posting this in the wrong area.
Please any help or comments would be appreciated...Can anyone point me
in the right direction on what will be involved with that type of
site?

Thanks again...

Before, I make this site though, I don't know where to get started.
The site will be a game site, and I'd hoped to just load all of the
flash swf's into a folder, then use controllers to call each one. I
plan on having tons of game though, so is there an easier way to
generate urls for them, and creating an index page that will list
games? Could I create a database that includes columns such as path
to .swf, title, description, and genre? Then automatically call them,
when the user types in a path.

That's pretty much what you get for free with rails if you generate a
scaffold.
The only difference is that by default rails will generate urls like /
games/123 (ie using the database id of the corresponding row) but you
can easily work around this (for exampl by overriding to_param in your
model)

Fred

I always have the same problem - learning everything is fun, but
actually putting a site into production takes a lot of thought and hard
work. Everyone has a different approach. I like to approach it like a
drawing, start with basic shapes, then slowly fill in the details.

Start with what you're familiar with. As a front-end designer, I like to
start with a basic HTML and CSS wireframe, as it gives structure to the
information. Then I look at all the information I'm going to need for
the page, and build my database structure (and thanks to migrations, I
can easily fill in all the stuff I miss later). For example, you'll
probably want to (at the very least) have a table called Games, where
you store the name of the game, the url, and the other relevant info for
it.

After I've got my db tables made, I flesh out my models, set up things
like validations, relationships, and methods I know I'm going to need.
Then I might start building my controllers, only to return to the models
to write new methods and re-factor others, based on how I see my
controllers functioning. (try to keep the controllers as free of
business logic as possible).

I would also recommend using RESTful controllers. It's kind of a
complicated topic for your first foray into rails, but I find that by
working with the constraints it enforces on your controllers, it
requires you to think more about the actual design (coding-wise) of your
site. Totally optional though.

I personally don't bother with scaffolding. I don't think it does a
whole lot to teach you about making a rails app. It's nice to see once
or twice, but after that, building everything from scratch is a lot more
educational.

Also, as far as the url scheme is concerned, you just have to set up
your routes in routes.rb. Something like:
  map.game "/games/:game_name", :controller => 'games', :action =>
'show'

The reality of it is that nobody can really tell you exactly what you
need to do. You just have to jump in somewhere and start hacking away.
Thankfully, both this forum and the net at large are excellent resources
for when you're stuck. I would also recommend getting at least one book
on the topic. Agile Web Development with Rails is fantastic when you're
beginning. Once you're comfortable with the basic topics, you might
check out The Rails Way as it deals with more advanced topics. Also, one
of the best things you can do for yourself as you learn rails is to
really make yourself familiar with Ruby. That's pretty key.

Good luck.

Sorry, I forgot to include some specific info about how you might want
to structure you controllers.

I would have a model named Game to represent each game. Then in the
games controller, you'd use something like:

GamesController

def index
@games = Game.find(:all)
end

def show
@game = Game.find(params[:id]) #where params would come from the link
to a game
end

Thanks for both of your replies. They helped as much as I could have
hoped. Now I will have to plot out exactly what I'm going to do, and
then answer the more specific questions later.

Thanks

Thanks for both of your replies. They helped as much as I could have
hoped. Now I will have to plot out exactly what I'm going to do, and
then answer the more specific questions later.

Thanks

Sorry, one other question: I'm going to be entering a lot of data into
the database, and the way I learned to enter data for ruby on rails is
through the command prompt. Is there an easier, more graphical way of
doing this, like a program. Is sqllite or mysql or phpmyadmin work
with ruby and database management? What do you guys use?

Sorry, one other question: I'm going to be entering a lot of data into
the database, and the way I learned to enter data for ruby on rails is
through the command prompt. Is there an easier, more graphical way of
doing this, like a program. Is sqllite or mysql or phpmyadmin work
with ruby and database management? What do you guys use?

cz231 wrote:

Sorry, one other question: I'm going to be entering a lot of data into
the database, and the way I learned to enter data for ruby on rails is
through the command prompt. Is there an easier, more graphical way of
doing this, like a program. Is sqllite or mysql or phpmyadmin work
with ruby and database management? What do you guys use?

Any tool your prefer to use should do the trick. I'm on a Mac, so like
to use CocoaMySql as my basic db GUI.

However, rails does allow you populate your database using something
called fixtures. Fixtures are just YAML structured files that map to
your db columns. Mostly, they're used for testing, but I find them
valuable for loading stuff into your development db as well. Fixtures go
in "/test/fixtures/fixture_name.yml" and you can load them with "rake
db:load:fixtures" in the command prompt

Here's an example of what one looks like. Notice you can embed ruby
code. It's YAML format, so whitespace does matter (just like your
database.yml file)

quentin:
  id: 1
  login: quentin
  email: quentin@example.com
  salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
  crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
  created_at: <%= 5.days.ago.to_s :db %>
  activation_code: 8f24789ae988411ccf33ab0c30fe9106fab32e9b
  activated_at: <%= 5.days.ago.to_s :db %>

aaron:
  id: 2
  login: aaron
  email: aaron@example.com
  salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
  crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
  created_at: <%= 1.days.ago.to_s :db %>
  activation_code: 8f24789ae988411ccf33ab0c30fe9106fab32e9a

Ok thanks,
I'm not sure if I can handle fixtures just yet...
So then, how do you configure the database manager to edit a database
for ruby?

Also, since I'm pretty new at databasing as well, I've already
described my scenario, so how would you setup up the database? One
table that is games. Then a column for path, name, and such. Then
should I also add a column for popularity and such that will be edited
automatically later? Or is there another way to do that?

Ok thanks,
I'm not sure if I can handle fixtures just yet...
So then, how do you configure the database manager to edit a database
for ruby?

Also, since I'm pretty new at databasing as well, I've already
described my scenario, so how would you setup up the database? One
table that is games. Then a column for path, name, and such. Then
should I also add a column for popularity and such that will be edited
automatically later? Or is there another way to do that?