Installation for Windows
- Execute the installer http://rubyinstaller.org/downloads
- Install rails, type in the console:
- gem install rails
- Install Ruby installer Develpment Kit from the same page
- Open the Ruby console and type :
- ruby dk.rb init
- ruby dk.rb install
- Install a timezone with TZInfo::Data
- Open file Gemfile
- Add the lines:
- gem 'tzinfo-data'
- gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
- Type: gem install tzinfo-data
- Type in the console: bundle update
- gem install rails
- Open the Ruby console and type :
- ruby dk.rb init
- ruby dk.rb install
- Open file Gemfile
- Add the lines:
- gem 'tzinfo-data'
- gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
- Type: gem install tzinfo-data
- Type in the console: bundle update
Files Structure
Rails.root -> Folder with your application name
|- app -> Models, Views and Controller code
|- bin -> Helper scripts (bundle, rails, rake)
|- config -> App, database & route configuration
|- db -> Database schema and migration
|- Gemfile -> Specify the required
|- lib ->
|- log -> Application logging directory
|- public -> Webroot of the application
|- test -> Tests (Agile development)
|- tmp ->
|- vendor ->
|- log -> Application logging directory
|- public -> Webroot of the application
|- test -> Tests (Agile development)
|- tmp ->
|- vendor ->
Create your First App
- Open a Ruby console
- Type: rails new app_name
- Review that appear a folder with your application name
- Type bundle check
Create MVC Components
- rails generate scaffold post title:string body:text
- scaffold - create all the pieces for MVC
- post is the scaffold's name
- title and body are part of the scaffold
- rails generate scaffold comment post_id:integer body:text
Create DB
- rake db:migrate -> In this case create post and comment tables
See URL
- rake routes
Run your application
- To run your application,type: rails server
- If you want details type: rails server -h
- Open a web browser at http://localhost:3000/
- Also can check with netstat -noa
Review the Database
- Download SQLite Database browser
- Go to your application folder
- Open the file development.sqlite3
Use GIT
Download from http://git-scm.com/downloads
- git init - create a repository for your application
- git add . - Versionised all files
- git status - Shows the files status
- git commit -m "my_message"
- git push origin master - Upload your files to the repository
Error Correction
ActionView::Template::Error ((in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/turbolinks-2.2.2/lib/assets/javascripts/turbolinks.js.coffee)):
Solution 1)
- Go to folder where Ruby is installed: C:/Ruby200-x64
- Find the file application.js
- Delete the line //= require_tree .
Solution 2) For Windows 8
- Go to folder where Ruby is installed: C:/Ruby200-x64
- Find the file runtimes.rb
- Back up the file
- Find the line :command => "cscript //E:jscript //Nologo //U",
- Remove //U
- Find the line :encoding => 'UTF-16LE'
- Change for :encoding => 'UTF-8'
Comentarios
Publicar un comentario