Ruby on Rails
Installation:
- curl -L https://get.rvm.io | bash -s stable
- --bash -sk stable < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
- [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
- rvm install 1.9.2(if you need 1.9.3 you change 1.9.3)
Rail instalation:
gem install rails r=3.2.11
Create New Project:
step 1 -->[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
step 2 -->rvm --create use1.9.2@name(gemset give any name)
step 3--> rails new blog(projectname)
step 4--> rm -rf Gemfile.lock
step 5->change gem 'mysql2' in GemFile
step 6-->bundle install(used for maintain rail version)
-->Exception
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
-->Solution
sudo apt-get install libmysqlclient-dev
step 7--> rake db:create
Exception:
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
solution
-->gem install execjs
step 8--> rails g scaffold Question(give your application name any name) title:string
questions:string answers:string(field name)
rails mysql or other
:binary blob
:boolean tinyint(1)
:date date
:datetime datetime
:decimal decimal
:float float
:integer int(11)
:string varchar(255)
:text text
:time time
:timestamp datetime
step 9-->-->rake db:migrate
step10-->rails server
step 11:open browser type url localhost:3000/ blog (projectname)
if you add model or controller to your application follow below instruction
model
rails g model User(modelname)
controller
rails g controller User (controller name)
mailer
rails g mailer user_mail(mailer name)
migration
scaffold
rails g scaffold Question(give your application name any name) title:string
questions:string answers:string(field name)
add new-column
rails g migration add_fieldname_to_tablename fieldname:string