This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.authenticate(login, password) | |
| return nil if login.blank? or password.blank? | |
| # need to get the salt | |
| if login.match("@") | |
| user = find_in_state :first, :active, :conditions => { :email => login} | |
| else | |
| user = find_in_state :first, :active, :conditions => { :login => login} | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## django | |
| from django.contrib.auth.models import User | |
| from django.core.validators import email_re | |
| class BasicBackend: | |
| def get_user(self, user_id): | |
| try: | |
| return User.objects.get(pk=user_id) | |
| except User.DoesNotExist: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Examples: | |
| // | |
| // button_to "Mark as unread", mark_as_unread_message_path(message), :method => :put, :class => "form_to_link" | |
| // button_to "New Alert", new_alert | |
| // | |
| jQuery(document).ready(function($) { | |
| var form_to_link = jQuery('.form_to_link'); | |
| var form = form_to_link.parents('form'); | |
| form.after('<a href="' + form.attr('action') + '" class="button_link_to">' + form_to_link.attr('value') + '</a>'); | |
| form.hide(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> Business.search(:conditions => { :state => "paid" }).length | |
| => 20 | |
| >> Business.find_all_by_state("paid").length | |
| => 321 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Interesting. |
NewerOlder