Friday, August 22, 2014

Steps by steps guilde to new rails app development


Creating a new rails app

rails new appfolder/appname

Installing the default gems

bundle install

Note : If you're developing Ruby on rails on Windows for the first time. you need the following command as libv8 usually doesn't support Windows.


gem install libv8 -v '3.11.8.17' -- --with-system-v8


Installing JQuery

add gem'jquery-rails' to your gem file and make bundle install
don't need to do rails g jquery:install from rails 3 as assets pipeline already take care of it.

Using Devise to generate User

add gem 'devise' to your gem file.

rails generate devise:install
rails generate devise User
rake db:migrate
rake routes

List of Devise default paths


new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
user_session POST   /users/sign_in(.:format)       devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
user_password POST   /users/password(.:format)      devise/passwords#create
new_user_password GET    /users/password/new(.:format)  devise/passwords#new
edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                         PUT    /users/password(.:format)      devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
user_registration POST   /users(.:format)               devise/registrations#create
new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy


If you want to customise the views for the devise, you could call the following rails command.

rails generate devise:views

Code scaffolding with rails

rails g scaffold Food user_id:integer title:string description:string categor
ies:string icon_url:string screenshot_url_01:string

Generate only controller class

rails g controller StaticPages

Installing Redis and Sinatra for API development

gem install redis
gem install sinatra
gem install sinatra-params-validator


Installing puma server ( not working for now)

gem install puma 
or for Windows, you have to pass with the path to openssl 

http://packages.openknapsack.org/openssl/openssl-1.0.0k-x64-windows.tar.lzma

  1. install DevKit, e.g. in c:\devkit
  2. unpack the OpenSSL Package, e.g. in c:\openssl (use 7Zip or PeaZip)
  3. You need to copy the ddls from the bin directory (libeay32.dll andssleay32.dll) to your ruby/bin directory.
  4. open a windows console
  5. initialize the DevKit build environment
    c:\devkit\devkitvars.bat
  6. Now it’s possible to install the puma gem with the OpenSSL packages
    gem install puma -- --with-opt-dir=c:\openssl
C:\>mkdir C:\Knapsack\x64-windows
C:\>cd C:\Knapsack\x64-windows
C:\Knapsack\x64-windows>bsdtar --lzma -xf openssl-1.0.0k-x64-windows.tar.lzma
C:\>gem install puma --platform=ruby -- --with-opt-dir=C:/Knapsack/x64-windowsgem install puma --platform=ruby -- --with-opt-dir=C:/Knapsack/x64-windows

No comments:

Post a Comment