Become web developer using Ruby on Rails

If you are a newbie to programming and want to become web developer means the best place is to start with Ruby on Rails shortly called as (ROR), Ruby is easy to learn language and ROR is fully configured frame work so you can directly work with your first database backed website with in a days.

In this article, I will give you idea about where you to start and end. There are four steps involved in web development they are.

  • Getting knowledge in basic things like HTML,CSS,JS
  • Familiar with databases and database queries
  • Basics of ruby
  • Learning ROR
  • Going deep with ROR

 

  1. Basics

In my opinion he best place to familiar with HTML,CSS and JS is w3schools or tutorials point. Both have interactive tutorials so you can run your code directly on the browser, and they don’t charge for any tutorial.

HTML –       https://www.w3schools.com/html/

https://www.tutorialspoint.com/html/

CSS –            https://www.w3schools.com/css/default.asp

https://www.tutorialspoint.com/css/

JavaScript – https://www.w3schools.com/js/default.asp

https://www.tutorialspoint.com/javascript/

2. Databases

Once you complete this you will familiar with how static websites are working, now it is the time to move with dynamic websites for this we have to study about databases. At first study about databases little bit and work with SQL databases (Later you may move to any database you wish).

For this also go with tutorials point, in Rails we don’t directly write database queries it is enough to understand basics of SQL and queries (for now).

SQL – https://www.tutorialspoint.com/sql/index.htm

3. Ruby

There are lot of ruby tutorials available in web, I will give you some quick way to learn ruby. Which will take minimal time and you can most of ruby syntax.

  1.  Ruby in 20 minutes https://www.ruby-lang.org/en/documentation/quickstart/
  2. Study Little book of ruby (Even though this book is older it is enough for understanding basic syntax of ruby) http://www.sapphiresteel.com/IMG/pdf/LittleBookOfRuby.pdf
  3. If you time and wish to learn ruby more try with this free tutorial https://www.codeschool.com/courses/try-ruby (Other ruby course in codeschool will ask you money)

This will give you basic ideas about ruby language.

 

4. Ruby on Rails

For beginner I will suggest only two websites to learn ruby on rails

  1. https://www.railstutorial.org/book/beginning

This tutorial not only covers ruby on rails. It will cover many tools like git, testing, hosting application on heroku. For the first time, you feel difficulties. But finish this tutorials so that you will familiar not only with ROR and also with code versioning, testing, deployment.

2. https://www.theodinproject.com/home

This is open source project, Covers most of the things including html,CSS, JS, Ruby, ROR.

5. Deep with ROR

Now you know how to create ROR application and work with that app.  Now it is the time to learn more things on ROR. I will give you some of the places where it is useful to spend time.

  1. Ruby Guides http://guides.rubyonrails.org/
  2. http://railsforzombies.org/
  3. http://tutorials.jumpstartlab.com/projects/blogger.html
  4. http://railscasts.com/

 

 

Advertisements

Ruby on Rails application Deploying in Heroku

Deploying ROR application in heroku is not a rocket science  now but some developer is having some confusion with this thing so only this blog post , So this post not for experienced developers 🙂

The first thing you need to understand heroku uses git for deployment , so that you need to have git repository in your ROR application first .

Then you need to install heroku toolbelt go here to get tool-belt for your OS , then install heroku gem

gem install heroku

If you don’t have heroku account create one https://id.heroku.com/login, then on your terminal type

heroku login

It will asks your credentials give them, then go to your application directory by terminal and type

heroku create optional-app-name

If you give application name it will create DNS same like that otherwise it will generate one for you.Then type

git push heroku master

It will push your code to heroku , It uses SSH to access , This is first time in your system to connect with heroku and using SSH means , type

ssh-keygen -t rsa

heroku keys:add

note: Heroku uses pg as default data base, so please ensure you have included gem ‘pg’ in your gem file.

If you have any problem with ssh see https://devcenter.heroku.com/articles/keys

Multiple model search in rails with solr

lrSearching is much easier if you use solr or elastic search, no need to write complex database queries.

If you want to integrate solr with your rails application means there is a gem available https://github.com/sunspot/sunspot

Add to Gemfile:

gem 'sunspot_rails'
gem 'sunspot_solr' # optional pre-packaged Solr distribution for use in development

Bundle it!

bundle install

Generate a default configuration file:

rails generate sunspot_rails:install

If sunspot_solr was installed, start the packaged Solr distribution with:

 bundle exec rake sunspot:solr:start

Then add the following code in model file which you going to search

searchable do
  text :<field_name>
end

In your controller queries

@search = Project.solr_search do
fulltext params[:search]
end
@projects = @search.results

Thats all, if you pass search params from your view file, then solr will give you the relevant projects.

Now I will show you how to search multi models in same querie,

simply add the same

searchable do
 text :<field_name>
end

In model files which you need to search, Then in your controller

@search = Sunspot.search(Project,Comment, File) do |s|
 s.fulltext(params[:search])
end

@result = @search.result

will give you the result from project, file and comment models


					

Easy Ruby on Rails install

Whenever I setup new Linux for developing rails application. I feel bit tired of installing all necessary things for rails development.

For that I have written one shell script, that install most of the things requires for rails development. If you want this lazy thing. You can check here

https://github.com/navinspm/easy_rails

And use it , fork the code and update if you feel some thing to be added.

Thanks.

Audio Streaming in Ubuntu using Shoutcast and Internet DJ Control

     If you ever want to stream your rails application audio file using shoutcast I will show you how to do this

firt install and configure shoutcast
cd /tmp
wget http://download.nullsoft.com/shoutcast/tools/sc_serv_1.9.8_Linux.tar.gz

If you get error while trying to execute this command then you don’t have wget command installed to your system. For Debian and Ubunutu use the following command to install it:

Code:
apt-get install wget

Again If you get the error then go to the shoutcast site then download the package

 Next we need to create the folder for our shoutcast server and extract the archive

Code:
mkdir /home/shoutcast
tar -zxf sc_serv_1.9.8_Linux.tar.gz -C ./home/shoutcast

Navigate to the shoutcast folder and clear the config file because it has comments and configuration codes it may confuse you if you see them first time any way its better to clear the file

Code:
cd /home/shoutcast
echo > sc_serv.conf

5. Open the file sc_serv.conf

Code:
nano sc_serv.conf

Paste the following text

Code:
 MaxUser=32
 Password=changeme
 PortBase=8000
LogFile=sc_serv.log
RealTime=1
ScreenLog=1
ShowLastSongs=10
SrcIP=ANY
DestIP=ANY
Yport=80
NameLookups=0
 AdminPassword=adminpass
AutoDumpUsers=0
AutoDumpSourceTime=30
PublicServer=default
AllowRelay=Yes
AllowPublicRelay=Yes
MetaInterval=32768

You should modify these settings:

A. Change the MaxUsers , It can be many users but set minimum as possible
B. Set the Password to a value that you know because you need it to connect to the server in order to stream music to it.
C. Optionally you can change the port by changing the PortBase to some different port.
D. AdminPassword is the web interface password. Web interface is used for banning and kicking users from the server.

6. Start the server

Code:
screen
./sc_serv

Thats all next is to go for broadcaster software in windows and mac SAM broadcaster is a excellent software we have but If you  want to use ubuntu then InternetDJcontrol shortely called as IDJC

IDJC

first we need to install idjc

Code:

sudo apt-get install jackd qjackctl

then

Open Limits.conf

sudo gedit /etc/security/limits.conf

Add the following lines into the file :

@audio - rtprio 99
@audio - memlock unlimited
@audio - nice -19

then run idjc you can find it by searching IDJC in ubuntu search bar This is GUI of IDJC

 main

Go to view-> output you will see the window like this there go to configuration -> connection -> new and fill the details as shown then click OK

host

then in configuration -> format fill the details as follows

configuration image

configuration setting

If all set to correct then above localhost:8000 (8000 may change depends on port you set)  will appear as shown if not check the settings againlocalhost then click the localhost:8000 button if everything goes well the button has need to be stayed as pressed like this  then the green light will glow

connectedand that’s all you may listen your radio on shoutcast.com by searching your radio name which you given at the first time you starts the IDJC , if the green indicator doesnot glow check the shoutcast server running and see the serv.conf file port setting

If you want to use it in your rails application the jplayer fetch the stream and play it well check it on their website jplayer stream player

 

Thank you for reading me…………………