Skip to content

Commit

Permalink
Merge pull request #3 from blairanderson/readme
Browse files Browse the repository at this point in the history
readme / howtorails
  • Loading branch information
blairanderson committed Aug 29, 2015
2 parents c0b7055 + 691e71f commit b347962
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 32 deletions.
63 changes: 63 additions & 0 deletions HOWTORAILS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Make a Website with my Woes

So you want to make a website, and you hear rails is a good place to start?!?!
Good choice, in all honesty i'd recommend learning whatever your friends(someone to ask for help when you get stuck!) know.

Lets get to it!

## WTF is a Website Anyways?!

Good question! Have you ever written an essay before? And then saved the text file and emailed it to yourself? Well, that text file is a real thing on your computer, its a **TEXT** file.

>the files are in the computer
Have you listened to music on itunes before? Songs are **MP3** files.

#### Computers hold files, and there are many many **types** of files.

**Answer:** A website is an **HTML** file. Similar to a text file, but a little bit different.

#### Let me explain...

When you open chrome(firefox, etc.) and type in http://www.facebook.com/ your computer is saying 'hey facebook, give me an html file for facebook.com!' and then facebook says 'ok, heres a file' and gives your browser an HTML file :)

When you make a website, you're basically making a thing that gives people these files when they request it.

Notice that visiting *facebook.com* is different than *facebook.com/friends* ... one is the home page, and one is the "friends" page.

These(*facebook.com* and *facebook.com/friends*) are called URLs/addresses/links. Kinda like how houses in your neighborhood have addresses, websites have addresses for each section of their site.

# How To Rails

Rails is a cool way to send people HTML when their browser requests it. Mostly because rails is easy for the person building the site!(YOU)

From now on, instead of the word "Website", we're going to call it the "App". its a shorter word, and more generic. trust me.

Rails helps you build **Apps**(websites)!

In a rails app, when someone requests your home page(root), it goes to the router!

you can look at the router inside [config/routes.rb](config/routes.rb)

The router for this app looks like this:

```ruby
# config/routes.rb

Rails.application.routes.draw do
root to: 'items#index'

resources :items, except: [:destroy] do
resources :item_comments
end

resources :users, except: [:index]
resources :user_sessions, only: [:new, :create, :destroy]

namespace :admin do
root to: 'items#index'
resources :items
end
end

```
33 changes: 1 addition & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,4 @@ $ bundle exec rake db:seed

```

*Lets look at some code*

When someone visits your website, they're literally just *request*ing some HTML, CSS, and Javascript! *requests* come to your application through the ROUTER.

```ruby
# config/routes.rb

Rails.application.routes.draw do
resources :items, except: [:destroy] do
resources :item_comments
member do
post :toggle
post :vote, to: 'user_item_votes#create'
delete :vote, to: 'user_item_votes#destroy'
end
end

root to: 'items#index'

resources :users, except: [:index]
resources :user_sessions, only: [:new, :create, :destroy]

get 'login' => 'user_sessions#new', as: :login
match 'logout' => 'user_sessions#destroy', as: :logout, via: [:get, :post]

namespace :admin do
root to: 'items#index'
resources :items
end
end

```
## [Lets look at some code](/HOWTORAILS.md)

0 comments on commit b347962

Please sign in to comment.