Senior & Expert RoR Developers Discussion Forum by Nyros Technologies

HIRE Ruby on Rails Expert Developers Programmers Coders From India
Ruby on Rails PHP .Net Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

Acts as Authenticated Plugin.

 
Post new topic   Reply to topic    Senior & Expert RoR Developers Discussion Forum by Nyros Technologies Index -> Plugins and Gems
View previous topic :: View next topic  
Author Message
swaminadhan



Joined: 14 Sep 2009
Posts: 84

PostPosted: Thu Nov 19, 2009 11:52 am    Post subject: Acts as Authenticated Plugin. Reply with quote

hello friends !

Most of the sites will have the authentication functionality.For that we can write our own code based on the conditions. And for this we do have, different plugins for the authentication property.One of the plugin for authentication property is Acts_as_Authenticated.

So let us discuss about the Acts_as_Authentication plugin for the Authentication and its advantages :

1. First of all we have to install the plugin in our application.

To install the plugin in your application do

ruby script/install plugin http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated

The plugin will be installed in your app/vendor/plugins.
Once the plugin gets installed.we have to generate the generator.

2. Rails will have the basic authentication generator.. To run this generator do

ruby script/generate authenticated user account.
Here the user is the model and account is the controller.

So once we run the above command automatically the model and controller will be created with the predefined methods.

3. Once do rake db:migrate for migrations.

4. Now run the server --- ruby script/server.

Now you are up with the Authentication Functionality.

Generally, we have to code a lot to get this functionality without installing the plugin.Lets check the advantages of this plugin

1. In this plugin we have a method 'logged_in?' . It will return true when the user gets authenticated or return false when user authentication fails.

2. In this plugin we have a method 'current_user' . In which it will get the details of the authenticated user.so that we can get the authenticated user details by using this method name directly. When we didnt use this plugin normally we have to declare a variable and we have to get the details into that variable and after that we have to use this variable inorder to get the user details.

for example:

When we wants to get the user details of the authenticated user we have to
@var=var.find(session[user_id])
so instead of using this we can use directly the "current_user" method.


3. Similarly filter method to enforce a login requirement.To require logins for all actions, use this in your controllers use:

before_filter :login_required

4. To require logins for specific actions, use this in your controllers:
before_filter :login_required, :only => [ :edit, :update ]

5. Similarly we have 'redirect_back_or_default(default)' method .

def redirect_back_or_default(default)
session[:return_to] ? redirect_to(session[:return_to]) : redirect_to(default)
session[:return_to] = nil
end

The advantage of this method is when we are not logged in,when we clicked on a particular url it will ask for the authentication,when we provides the login details it will directly take you to the url that you clicked before logged in. To write this functionality manually we have to code a lot.



Thank you,
swaminadhan
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert RoR Developers Discussion Forum by Nyros Technologies Index -> Plugins and Gems
Page 1 of 1

 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts Chat utility in a ROR application
0 shobana 2 Thu Sep 09, 2010 9:45 am
shobana View latest post
No new posts How to customize Google Maps InfoWindow using ym4r_gm
0 kalyanallampalli 54 Thu Sep 02, 2010 5:34 pm
kalyanallampalli View latest post
No new posts Drag and Drop file upload
0 umamageshwari 51 Wed Sep 01, 2010 9:36 am
umamageshwari View latest post
No new posts Flex On Rails
0 Raghu 48 Wed Sep 01, 2010 3:00 am
Raghu View latest post
No new posts MongoDB
0 Raghu 45 Tue Aug 31, 2010 3:30 pm
Raghu View latest post
No new posts Problem with Dreamweaver / java error
3 Raja 37 Tue Aug 31, 2010 3:24 pm
Raghu View latest post
No new posts Generating Model
0 phani.galla 44 Tue Aug 31, 2010 2:09 pm
phani.galla View latest post
No new posts Hide Panels using JQuery
0 Anu 48 Tue Aug 31, 2010 1:50 pm
Anu View latest post
No new posts Load a text file using ajax in jquery
0 Anu 38 Tue Aug 31, 2010 1:39 pm
Anu View latest post
No new posts Generating Migrations
0 phani.galla 31 Tue Aug 31, 2010 1:38 pm
phani.galla View latest post




Hire an expert Ruby on Rails developer / coder / programmer or development team from India now!!

Other Forums : PHP   ::   .Net   |   Free unlimited HTML CSS templates download

Nyros Technologies   |   Kakinada City Portal   |   Developers Blog   |   About Ruby on Rails Experts   |   More