Build a beautiful Active Admin interface using Active Admin themes

As we know Active Admin (https://activeadmin.info) is a popular Ruby on Rails plugin to generate admin interface.  It has many benefit over currently existing other similar plugin like Rails Admin. Active Admin gives the facility to customize pages, layouts. Here is simple demo of Active Admin with default theme http://demo.activeadmin.info/admin. Beside this default theme, you…

Read more...

Rails Tips: ActiveRecord Conditional Validation

In my User model, I have to check validation presence of state only for users from Nepal. No need to check validation for the users from other country. For this I have implemented as follows: class User < ActiveRecord::Base validates_presence_of :state, :if => :in_nepal? private def in_nepal? country == ‘Nepal’ end end Here country is…

Read more...

Conference I attended: RubyConfIndia (Ruby Conference India)

RubyConfIndia (http://rubyconfindia.org) is a global event complementing other RubyConf events across the world. This is India edition of ruby conference. This year RubyConfIndia was happened in Bangluru on 9th and 10th Feb 2018. I got chance to attain this event. The event was started with the Keynote talk by Avdi Grimm (@avdi) and closed with…

Read more...

Ruby Gemset

What is Gemset? A Gemset is just a container you can use to keep gems separate from each other. We create separate gemset for different project which only have required gem with version for the particular project. It is a separate directory with version of various gems you are using. Why Gemset? The Big Idea:…

Read more...

Rails tutorial: Upload image with paperclip gem

Paperclip is intended as an easy file attachment library for Active Record. Paperclip is ruby gem which helps to upload image or attachment in rails application. We can upload attachment using paperclip gem in rails through following steps. Add paperclip gem to your Gemfile gem “paperclip” Install gem (run on command prompt): bundle install Create…

Read more...

Why college projects are important?

In my career I had taken more than 100’s of interviews in my company and the number is raising up. Most of candidate are freshers and some are experienced developers. Fresher candidate apply for entry level job whereas experience developers apply for mid-level and senior level position. Here I’m not talking about experience developers. There…

Read more...

Rails tutorial: Send email with rails

In rails we use ActionMailer to send email. For more detail about ActionMailer check this link: http://guides.rubyonrails.org/action_mailer_basics.html Now its time to create mailer. Use following line of command to create mailer. Here I created Blog Mailer which is used to send email to all blog subscriber when new blog published. rails g mailer ArticleMailer Which…

Read more...

Rails 5: redirect_to :back is not working?

In earlier version of Rails (<5.0) we used redirect_to :back to go previous page. With this method we got ActionController::RedirectBackError error when HTTP_REFERRER is not present. This may happen when we refresh the page. To fix this problem we have new method called redirect_back method as following: redirect_back fallback_location: root_path It will redirect to the…

Read more...

Rails SMTP configuration in runtime

SMTP is mail delivery method in rails  which is used to send email through rails. Setting of SMTP is configured in different environment like development, production and test. For this we configure following setting in different file like config/environments/development.rb, config/environments/production.rb, config/environments/test.rb with respect to different environment.  config.action_mailer.smtp_settings = { address: “smtp.gmail.com”, port: 587, domain: “mail.google.com”,…

Read more...

Rails tutorial: Simple blog subscription feature in Rails

Here is a simple Rails MVC tutorial guide. This step by step tutorial will help you to configure routes, generate model, controller and view (i.e. MVC). It will also teach you how to send email using ActionMailer in Rails. Before start this you have to setup new rails application with MySQL database. My previous post…

Read more...