Skip to main content

Posts

Showing posts with the label ruby on rails programming

Virtual Studio Code for Ruby on Rails Development

Introduction to Vscode (Visual Studio Code) Visual Studio Code i.e. Vscode is a modern and robust code editor developed by Microsoft. We can use it for setting up Ruby on Rails development environment. It combines the simplicity of code editor with powerful tools like IntelliSense, code completion, debugging and built-in Git support. One of the beauties of Vscode it's free and open source. It is available for Windows, Mac, and Linux with huge community support.  How to Install Vscode? Installation steps of Vscode are pretty simple, go to  Visual Studio  it will automatically detect the operating system you are using and provides a download link. After installation, you are ready to start customizing Vscode for Rails development. How do you set up Vscode for Rails? ·  Ruby extension: The first thing you have to install the ruby extension in Vscode. Press  f1 , type  ext install  then sea...

How to combine data from two different tables into new rows to be displayed as one table in Rails application?

Let’s start with an example that you have two different tables called InternalEmail and ExternalEmail. internal_emails Id (integer) sender_id (integer) content (text) Subject (character varying) recipient_email (character varying) Status (character varying) created_at (timestamp without time zone) updated_at (timestamp without time zone) 1 52 internal_content_1 internal_subject_1 44 accepted 2016-10-21 00:49:24.991002 2016-10-21 00:49:24.991002 2 46 internal_content_2 internal_subject_2 43 rejected 2017-10-21 00:49:24.991002 2017-10-21 00:49:24.991002  external_emails Id (integer) sender_id (integer) content (text) Subject (character varying) receiver_id (integer) opened (boolean) created_at (timestamp without time zone) updated_at (timestamp without time zone) 1 44 external_content_1 external_subject_1 42 true 2014-10-21 00:49:24.991002 2014-10-21 00:49:24.991002 2 42 external_content_2 external_subject_2 41 ...

Instagram API Integration to get Instagram feed to your website

To integrate the Instagram API in your website, you need you have to follow following process Log in to Instagram and open this page https://instagram.com/developer/clients/manage Click on the button «Register a New Client». Then Fill all the Mandatory fields, in Valid Redirect URIs specify your valid redirected URI and click «Register». Then click «Manage» button to obtain both Client ID and Client Secret of your just registered app. Use the Client ID and Client Secret to generate access token with this link https://rudrastyh.com/tools/access-token . You can find more info there as well. A Short Introduction about sandbox mode All newly created apps start in Sandbox Mode Apps in Sandbox mode have access only to 20 latest media of an access token owner (and sandbox users invited to your app). To avoid these restrictions you should send your app to approval. We can get instagram feed in our website by two ways By User ID By a Username How can...

Introduction of Docker Tools For Beginners

What is Docker? Docker is the world's leading software container platform. Docker is a tool designed to make it easier to deploy and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. Where does Docker operate? Design Development Deployment Testing/Release Docker makes the process of application deployment very easy and efficient and resolves a lot of issues related to deploying applications. Build app lication only once: An application inside a container can run on any system that has Docker installed. So there is no need to build and configure application multiple times on different platform. More Sleep and Less Worry With Docker you test your application inside a container and ship it inside a container. This means the environment in which you test is identical to the one on which the app...

Simple way to document API in Ruby on Rails using swagger document

After creating REST API, it’s important that API should be documented, so the others can use the documentation and understand the requirement and implementation of API. Swagger documentation provides the interface to REST APIs which allows people and system to understand the API without access to source code. Use ‘swagger-docs’ gem to document the API. This will generate swagger-ui json files for rails apps with APIs specification that can be used by person to know about the APIs. To start create swagger_docs.rb file in config/initializers and define your APIs as below: Swagger::Docs::Config.register_apis({ "1.0" => { :api_extension_type =>:json, # path for .json files :api_file_path =>"public", :base_path =>"http://api.somedomain.com", :clean_directory =>false, :attributes => { :info => { "title" =>"Swagger Sample App", } } } }) Swagger document contain the json controller which has ...

How to implement breadcrumbs functionality in Ruby on Rails app?

Breadcrumbs are graphical control element used as navigational aid in user interfaces. Today I am going to explain how it can be implemented in Ruby on Rails in simple steps as follows: Step 1: Create a sample app using scaffold Step 2: Add"breadcrumbs_on_rails" gem to the Gemfile and install it. Step 3: Create a home.html.erb in articles for home page and route for it. --> app/views/articles/home.html.erb Welcome This is the home page of Sample Article <%= link_to "Articles", articles_path%> --> config/routes.rb root 'articles#home' Step 4: Add breadcrumb for home page. In Articles Controller create method “add_breadcrum” to set the braedcrumb for home path like this: --> app/controllers/articles_controller.rb defadd_breadcrum add_breadcrumb " Home ".html_safe end For every view page set home page as the first breadcrumb in articles controller by the default using: before_action :add_breadcrum...

How to create Drag and Drop functionality in Ruby On Rails?

I have seen many developers that are looking for creating "Drag and Drop" functionality in Ruby On Rails technology. So I'm going to brief about a sample to create and implement this functionality using JQuery Rails, JQuery UI Rails and Rails Sortable gems. Given below are simple steps required to create the rails application: Ruby On Rails Programming How to create Drag and Drop functionality in Ruby on Rails? First of all we will create a simple application first to create the products. The first Step we required to create the Rails Application. $ rails new SampleSortRails By using the scaffold we will generate the the MVC components needed for Simple Products application form $ cd SampleSortRails $ rails g scaffold Product name:string description:text quantity:integer price:integer sort:integer Create the Products database table: $ rake db:create $ rake db:migrate Rails uses rake commands to run migrations. Migrations are Ruby clas...