Difference between revisions of "Rails3"
(→Nonstop first app) |
|||
Line 25: | Line 25: | ||
Enter the new web page content: |
Enter the new web page content: |
||
<h1>Hi there!</h1> |
<nowiki><h1>Hi there!</h1></nowiki> |
||
Set up the new root page |
Set up the new root page |
||
Line 36: | Line 36: | ||
... |
... |
||
Test your server |
Test your server at http://localhost:3000 |
||
rails server |
rails server |
||
=== Create scaffolding == |
|||
rails generate scaffold Post name:string title:string content:text |
|||
rake db:migrate |
|||
== Using Mysql == |
== Using Mysql == |
Revision as of 18:12, 28 December 2010
Developing for Rails3.
Create a new application
Test your installation by making a test application
rails new tetsApp cd testApp rails server
Now check the http://localhost:3000 in your browser.
Nonstop first app
rails new blog cd blog bundle install
gedit config/database.yml rake db:create
rails generate controller home index gedit app/views/home/index.html.erb
Enter the new web page content:
<h1>Hi there!</h1>
Set up the new root page
rm public/index.html gedit config/routes.rb
Edit routes, like this
... root :to => "home#index" ...
Test your server at http://localhost:3000
rails server
= Create scaffolding
rails generate scaffold Post name:string title:string content:text rake db:migrate
Using Mysql
Making a new application
database.yml file
development:
adapter: mysql2 encoding: utf8 database: blog_development pool: 5 username: root<change this> password: <change this> socket: /tmp/mysql.sock
Using Postgres
Make sure you have pg gem installed (not the old "postgres" gem)
gem install pg
Making a new application
rails -d postgresql my_rails_app
database.yml file
development: adapter: postgresql host: localhost port: 5432 username: your_db_username password: your_db_password database: your_rails_project_development schema_search_path: public encoding: utf8 template: template0
More info
Try this: http://wiki.rubyonrails.org/database-support/postgres