Posts

Showing posts from 2015

Install Ruby on Rails on Mac

Please follow the below steps to i nstall RVM RUBY RAILS and Postgres in MAC yosemite. Step 1. Install Homebrew Homebrew is a package manager for the Mac. Installing Homebrew by issuing the following command: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install) " To make sure Homebrew is installed correctly run: brew doctor Step 2: Install GPG Package. Download and install the GPG package from the link https://gpgtools.org Step 3: Install RVM gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 and \curl -sSL https://get.rvm.io | bash -s stable Reload your bash_profile, so it can initialize RVM. ~/.bashrc Run RVM requirements to install basic required packages with Homebrew. Accept the license agreement and install Xcode Tools. After installing the tools continue the rvm requirements installation. rvm requirements Step 4. Install Requir

Create Nested form In Ruby on Rails 4.1

In Rails we create simple form and also sometimes we need nested form. In Rails we can easily do that using  gem “nested_form”. let's create a project using “nested_form”. Before that I would like to ask you to have a look on nested_attribute_documentation(http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for). 1) Create a new Rails 4 Project.     rails new nested_app 2) Include the gem in your gem file.   gem "nested_form" 3) run bundle install  bundle install 4) Generate the necessary javascript file.   rails g nested_form:install 5) Include the javascript file in the asset pipeline. in the application.js add the below line.   //= require jquery_nested_form 6) Let say we have a Exam model and one Exam can have multiple Questions.So lets create the Exam model. class Exam < ActiveRecord::Base   has_many :questions, dependent: :destroy   accepts_nested_attributes_for :questions,