Wednesday, 8 May 2013

Twitter gem for Rails : How to share dynamic contents to Twitter from your Rails Application

Before going through this post . I would suggest you to go through my previous FB share  post. You will get to know the basic functionality & working from the prev post .After that please go through Twitter gem description.

I hope you have gone through the prev post and you have got some idea about it.

Now we will start with Twitter share implementation.You have to include  "twitter" & "oauth" gems into your Gemfile.

gem 'twitter'

gem 'oauth'

Compared to FB share , here we need to include "Oauth" gem for authenticating the user to twitter and redirect the user back to your applications Callback action.After getting the Oauth Secret Key i.e returning from Twitter you can configure the Twitter gem settings and you can post to twitter from your Rails app.

Tuesday, 7 May 2013

Fb Graph Gem for Rails : How to Post dynamic contents to Facebook Wall from your Rails Application

This post will introduce the usage of fb_graph Gem with your existing Rails Application.fb_graph has already done a lot for you guys to exploit the FB API features with your Rails Application , you can have an eye on this fb_graph Gem before going through this post.

Suppose you have a blogger kind of application, and when you compose a new post , you would like to share the same in your Facebook wall, and also would like to give the same option for all the users ,those who liked your post and would like to share the same in their Facebook Wall.

I think now almost all the websites are using this feature to increase their user traffic , to popularize their sites,  Since Facebook turned out to be a great option for advertising and marketing your site content.

One day i also felt the same and after one complete days of effort ..... i was successful.            I thought i should share the same for you guys to reduce your one days effort ( or may be less ) for implementing this FB share option.

I hope i am not boring you , anyway stop to all kind of rubbish introduction and lets start coding ..

Thursday, 17 January 2013

Ruby On Rails: Omniauth Devise Authentication using Facebook , Google & Twitter.


This post is just a simple straightforward description of Omniauth:Overview , intended for the beginners , those who wants to try the OmniAuth for the first time with Facebook , Google & Twitter. This post will cover all the basic information i.e From creating the app in Facebook, Google & Twitter for getting the secret key To connect these Apps to your Rails Application.

Things in common :

add Devise & omniauth gem to your Gemfile.

gem 'omniauth' 
gem 'devise' 

First of all install Devise into your application.
rails generate devise:install  
You have to create user model using devise ,
rails g devise user  
and after that we need to add 2 more columns i.e "uid" and 'provider' to our user model.

rails g migration AddColumnsToUsers provider:string uid:string
rake db:migrate
 also dont forget to add ":provider" and ":uid" to your attr_accessible also.

 We have done with the things that is common in authentication using facebook,Google, Twitter.

 We will start with Facebook Authentication first 

 Facebook Authentication :

 add gem 'omniauth-facebook' to your gem file.

 First of all you need to create an application in facebook to get the secret key out .


Sunday, 9 December 2012

Operator Overloading in Ruby

I expect many of you know that Ruby permits Operator overloading .Many of Ruby's operators are implemented as methods, you can define or redefine how these methods or  operators should work in your own classes , here i am trying to mention some fun facts that we can do with ruby.

I expect all of you should be knowing this , may be better than me as well . But this is a just a simple but strait forward example for the beginners like me,  those who wanted to experiment more on Ruby. 

Creating a class called ClassA

class ClassA
  attr_accessor :value
  def initialize(value)
    @value = value
     puts "Object of ClassA with value #{@value} has been created"
  end
 end
and Instantiating one obj of ClassA,

a=ClassA.new(10)
Object of ClassA with value 10 has been created
What if ruby permits a behavior like you can add objects of 2 different classes , then you are receiving the output without creating any scene , it will be fun right.