Skip to content

Commit

Permalink
format README to be readable
Browse files Browse the repository at this point in the history
  • Loading branch information
samgooi4189 authored and samgooi4189 committed Oct 7, 2012
1 parent 77fe47d commit 3f1ade7
Showing 1 changed file with 54 additions and 49 deletions.
103 changes: 54 additions & 49 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,69 +10,74 @@ Experiment rails and detect common FAQ
* git init<br /> * git init<br />
* git add .<br /> * git add .<br />
* git commit -m "First Push"<br /> * git commit -m "First Push"<br />
* git remote add origin https://github.com/blabla/bla.git * git remote add origin https://github.com/blabla/bla.git<br />
&lt;https is your github repo url&gt;<br /> &lt;https is your github repo url&gt;<br />
* git pull origin master * git pull origin master <br />
&lt;if you create a readme in git&gt;<br/> &lt;if you create a readme in git&gt;<br/>
* git push origin master<br/> * git push origin master<br/>
&lt;you are done&gt; &lt;you are done&gt;




check status: <h2>check status:</h2>
git status / git log * git status / git log


get started with changing index page: <h2>get started with changing index page:</h2>
rake db:create * rake db:create<br />
rails generate controller home index <=This will create a controller * rails generate controller home index<br />
& index.html.erb in app/views/home> &lt;=This will create a controller<br />
modify routes.rb change root :to =>"home#index" &amp; index.html.erb in app/views/home&gt;<br />
* modify routes.rb<br />
change root :to =&gt;"home#index"


Create resources using Scaffold: <h2>Create resources using Scaffold:</h2>
rails generate scaffold Post name:string title:string context:text * rails generate scaffold Post name:string title:string context:text<br />
<check db/migrate/...rb to view the database structure> &lt;check db/migrate/...rb to view the database structure&gt;<br />
<the def change is the function called when db migrate, creating tables with defined types> &lt;the def change is the function called when db migrate, creating tables with defined types&gt;<br />
rake db:migrate * rake db:migrate


To migrate db: <h2>To migrate db:</h2>
rake db:migrate <this will only effect development> * rake db:migrate<br />
If need to specify: &lt;this will only effect development&gt;<br />
rake db:migrate RAILS_ENV=production <h3>If need to specify:</h3>
\_\_\_ * rake db:migrate RAILS&lowbar;ENV=production


To set validation on creating new record: <h3>To set validation on creating new record:</h3>
go to app/model/post.rb, and add this into Class:" * go to <b>app/model/post.rb</b>, and add this into Class:"<br />
validates :names, :presence => true validates :names, :presence =&gt; true<br />
validates :title, :presence => true, validates :title, :presence =&gt; true,<br />
:length => {:minimum => 5} :length =&gt; {:minimum =&gt; 5}<br />
" "<br />
This will ensure names and title need to filled before submit. This will ensure names and title need to filled before submit.


To load the updated code while in console: <h2>To load the updated code while in rails console:</h2>
<run> reload! * reload!


Before bundle with pg: <h2>Before bundle with pg:</h2>
sudo apt-get install libpq-dev * sudo apt-get install libpq-dev


Deploy to heroku: <h2>Deploy to heroku:</h2>
add gem 'heroku' in Gemfile * add gem 'heroku' in Gemfile<br />
configure Gemfile: * configure Gemfile:<br />
group :development, :test do group :development, :test do<br/>
gem 'sqlite' gem 'sqlite'<br />
end end<br/>
group :production do group :production do<br />
gem 'pg' gem 'pg'<br />
end end<br />
sudo apt-get install postgresl <if you dont install postresql locally, you wont able to install pg> * sudo apt-get install postgresl<br />
bundle install &lt;if you dont install postresql locally, you wont able to install pg&gt;<br />
heroku run rake db:migrate * bundle install<br />
type in command: * heroku run rake db:migrate<br />
wget -qO- https://toolbelt.heroku.com/install.sh | sh * <b>type in command:</b> <br />
heroku login wget -qO- https://toolbelt.heroku.com/install.sh | sh<br />
git add . heroku login<br />
git commit -m "init deploy" git add .<br />
heroku create <will create new app at heroku> git commit -m "init deploy"<br />
heroku key:add <if you dont have rsa key stored at heroku yet> heroku create<br />
git push heroku master &lt;will create new app at heroku&gt;<br />
heroku key:add<br />
&lt;if you dont have rsa key stored at heroku yet&gt;<br />
git push heroku master<br />






0 comments on commit 3f1ade7

Please sign in to comment.