Rails Authentication redirect back after authentication

Plz, go to this url….

Rails Authentication redirect back after authentication

 

 

I was in the same situation:

If you are like me,and Ryan Bates, you like doing the important things yourself.  If there are errors, they are your errors.
Chances are you will want to create your Rails authentication from scratch yourself. Ryan of Railscasts has an excellent screencast about this.

I switched from Devise to the  custom authentication using this screencast. It was a breeze.
So now comes the customisation. One of these is the all-important Rails authentication redirect back to the funnel a user came from after they are done signing in, or up.

This can actually be achieved very easily:

Force authentication

Force authentication

Say I have a CharitiesController, that I want to close to unauthenticated users. In line with Devise, I would do this to force them to authenticate:

Set a return point

In my ApplicationController, given i have set the user sign in route to user_login, I can define a return point:

%Q, %q, %W, %w, %x, %r, %s

ITs time we learn this Awesome language called as RUBY.

Simple Ruby on Rails

%Q | %q | %W | %w | %x | %r | %s

%Q

This is an alternative for double-quoted strings, when you have more quote characters in a string.Instead of putting backslashes in front of them, you can easily write:
>> %Q(Joe said: "Frank said: "#{what_frank_said}"")
=> "Joe said: "Frank said: "Hello!"""

The parenthesis “()” can be replaced with any other non-alphanumeric characters and non-printing characters (pairs), so the following commands are equivalent:
>> %Q!Joe said: "Frank said: "#{what_frank_said}""!
>> %Q[Joe said: "Frank said: "#{what_frank_said}""]
>> %Q+Joe said: "Frank said: "#{what_frank_said}""+

You can use also:
>> %/Joe said: "Frank said: "#{what_frank_said}""/
=> "Joe said: "Frank said: "Hello!"""

%q

Used for single-quoted strings.The syntax is similar to %Q, but single-quoted strings are not subject to expression substitution or escape sequences.
>> %q(Joe said: 'Frank said: '#{what_frank_said} ' ')
=> "Joe said: 'Frank said: '#{what_frank_said} '…

View original post 131 more words

Bind Show Hide Events With jQuery

For the chaining rule replace ‘el.apply(this, arguments);’ with “return el.apply(this, arguments);”

Maxime Parmentier

Here is a little snippet to allow you to bind events when dom elements are shown hidden with jQuery.

(function ($) {
  $.each(['show', 'hide'], function (i, ev) {
    var el = $.fn[ev];
    $.fn[ev] = function () {
      this.trigger(ev);
      el.apply(this, arguments);
    };
  });
})(jQuery);

And now bind the event on a specific dom element:

$(function () {
  $('div').on('hide', function () {
    alert('div hidden');
  });
});

View original post

User authentication with webapp2 on Google App Engine

Session using webapp2 in GAE(Google app Engine).

@abahgat's blog

Google App Engine for Python ships with the capability to manage user accounts without the need of any additional library. This functionality is, however, insufficiently documented. This post will be structured as a step-by-step tutorial addressing user registration, login, password reset and a few other details.

The webapp2 framework on Google App Engine for Python 2.7 is definitely a step forward from the original webapp.
Despite the increase in flexibility and functionality, however, there are a few items that are still more laborious than in other frameworks. The most notable aspect is user account management.

Unsurprisingly, since it is meant to run on Google’s App Engine, using Google Accounts with webapp2 takes one line of code. OpenID authentication, while still defined experimental, is almost trivial to implement as well. There are some open source projects like SimpleAuth that attempt to offer a standard and unified API to…

View original post 1,723 more words

Enable jinja2 and i18n translations on Google AppEngine

GAE and Jinja and adding filters and more, this may be useful dude.

Mikhail Shilkov's blog

My initial goal was to make our new application (based on python/AppEngine) translatable. This means the following requirements:

  1. All strings in the application must be translatable
  2. Translations should preferably stored in separate files
  3. It should be easy to use the translations both in .py files and html templates

The solution that I came to after a couple of hours includes the following components: Babel (string file generation), i18n.gettext (getting strings in code) and jinja2 <% trans %> tag (getting strings in templates). The setup of all this is not obvious, so I’ll put the steps in this blog post. Let’s start!

1. Intall Babel: http://babel.edgewall.org/
You need to install it, not just ref from the application, as you’ll need its comman ‘pybabel’ to generate locale-specific files. I use Windows, so I just downloaded the installation package.
Make sure that Python folders are in your PATH variable. I use Python 2.7, so…

View original post 262 more words

The Play of divs inside each-other.

THE DIV INSIDE IS A GOOD TOPIC TO COVER BECAUSE THERE IS A LOT OF CONFUSION  TO MAKE THIS THING WORK PROPERLY. SO I AM SHARING MY EXPERIENCE TO WORKING WITH DIVS.

let us make two dive like this

<div id=”outer”>

<div id=”inside’>

</div>

</div>

———————– css to play with ———————–

#outer{

width:200px;                 // 1.  if you don’t give the value of height and width then its OK.

height:200px;            // 2. IF you right that display:inline then all the inside div will have no effect of that. they will sit inside no matter if  display : block or display:inherit

border:5px solid gray;

display:inherit;     // if you give display:absolute then the whole div block will have the effect and still it will be good for inside divs

}

#inside                                       // this is the inside div

{

width:100px;

height:100px;

margin : 0px auto; // this will make it to move to the center of the outer div

position:      //( 1. if  :absolute then its ok , 2. if :static 3. if :relative then its ok . but relative will leave its not taking the full of width and height . )

display: block ; // display:box.  no effect same and its ok to have them

display :inline ;// give the behave like the pic 2 and all have the pic 1 effect

 

}

 

// ————————— pic 1———————————