INTRO TO RAILS
Building a Simple Twitter app
Building Twitter
Today we'll be building out a simple Twitter application that displays some tweets.
Modeling our solution
- What pages do we need to have?
- What questions / forms do we need to present the user?
- What things do we need to store?
Pages we need to build
- A page to create a new Twitter user
- A page to create a new tweet
- A page to list the tweets for a user
Things we need to ask for (and store)
- User:
- Tweet:
- Handle of user who tweeted
- Text of the tweet
Users
ID |
Handle |
1 |
@daretorant |
2 |
@cnn |
3 |
@iExperienceCT |
Tweets
ID |
User Id |
Body |
1 |
1 |
omg this cat is amazing |
2 |
1 |
can i keep it? |
3 |
1 |
seriously tho i want the kitty. |
Resources
Each unique type of data you want to store in your application is called a resource. This application has two resources:
Scaffolding
For each resource that we scaffold, we actually get more than what we need for free. For example, if we scaffolded a User resource, we'd get:
- A page that lists all of the users
- A page that lets you create a user
- A page that lets you edit a user
- A link that lets you delete a user
What are Routes?
Routes are the URLs that work in your web application. When you scaffold certain resources, it automatically creates routes (URLs for you to use). For example, scaffolding Users will give you /users, and scaffolding Tweets will give you /tweets.
What is a Rails View?
- A Rails view is a template that allows you to render HTML, but with some dynamic logic
- It's like an HTML file, except you can put Ruby logic in it to make it dynamic
Twitter App is GO
Congrats! You've built a Twitter app... this app will be enhanced further in the next lecture.
Save our Work
To save our work, let's create a local repository using Git, and then create a repository on GitHub to store our application code remotely.
Final Project: Proposal
- The biggest goal of this program is the final project.
- You should start thinking about what you want to build as your final project immediately.
- We will provide more clarity around its exact requirements soon, but in the meantime, spend some time thinking about what kind of app you'd like to build, and what features it would have.
- There are no examples of 'past projects'. You are the pioneers here. Set the standard for all those to come.