Posts

Showing posts from August, 2016

Integration of angular 2 tour of heroes with rails 5 api

Image
Hi fellas I know its been a hard journey of angular 2 tour of heroes but now once you are done with tour of heroes you may want it to integrate with Rails 5 api only application and to achieve that first you need a separate rails 5 api only application I have wrote a blog for rails 5 with hero resource just follow that and create a basic rails 5 api app with hero resource. http://nitanshu.blogspot.in/2016/08/initialization-of-rails-5-api-only.html In the json you see created_at and updated_at keys it will cause problems on the Angular 2 end since our app is only expecting the id and name attributes. Let’s take care of that right now since we’re already working on the Rails side. We’ll need to add the active_model_serializers gem to our Gemfile . gem 'active_model_serializers' bundle install mkdir app/serializers Create a new file called app/serializers/hero_serializer.rb with the following content. class HeroSerializer < ActiveModel::Serializer   att

Basic app in Rails 5 api mode

Image
  In Rails 5  you can create an app which will provide you only JSON API support. To do that actually there are two ways one is through rails gem and another is from git repo of rails I prefer rails gem: ================= First way(preferable) ================== To start with rails you need ruby version >=2.2.2 so first you need to install ruby-2.3.0 and rails 5 rvm install ruby-2.3.0 rvm use --default ruby-2.3.0 gem install rails -v 5.0.0 rails new my_app --api cd my_app rvm use 2.3.0 create a rvm wrapper for your application for that create two files one is .ruby-version and another is .ruby-gemset. In .ruby-version file type the current ruby version ruby-2.3.0 In .ruby-gemset file type the current ruby version @my_app now to initialize rvm wrapper cd .. cd - rvm current now you will see ruby-2.3.0@my_app bundle install ===================== Second way ===================== git clone https : / / github .com / rails / rails cd rails bundle in