Ruby Rail First Step: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 32: | Line 32: | ||
To create in production | To create in production | ||
<pre>rake db:migrate RAILS_ENV=production.</pre> | <pre>rake db:migrate RAILS_ENV=production.</pre> | ||
* Add Post Page in the index file app/view/home/index.html.erb | |||
<pre><%= link_to "My Blog", posts_path %> </pre> |
Revision as of 23:04, 14 November 2014
- Your first application with MySQL
rails new firstapp -d mysql
- Move into the application directory
cd firstapp
- If you setup MySQL or Postgres with a username/password, modify the
- config/database.yml file to contain the username/password that you specified
- Create the database
rake db:create
- Start the server
rails server
- Visite the web site
- change the default page
Add the following into config/routes.rb
root :to => "home#index"
- Generate a ressource
rails generate scaffold Post name:string title:string content:text
Creating and Customizing Rails Generators & Templates
- Create Tables
rake db:migrate
To create in production
rake db:migrate RAILS_ENV=production.
- Add Post Page in the index file app/view/home/index.html.erb
<%= link_to "My Blog", posts_path %>