This file contains 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. |
This file contains 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 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 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 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 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
<% form_for :listing, @listing, :url => listing_path(@listing), :html => { :method => :put, :class => "edit_post", :id => "edit_post_45" } do |f| %> | |
## method is still not put as described in the api. |
This file contains 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
## code | |
def listing_file=(file) | |
# self.listing_files.build.attachment = file | |
self.listing_files.create :attachment => file | |
self.listing_files.build(:attachment => file) | |
raise " | |
#{file} | |
---- |
This file contains 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
>> a | |
=> ["joe", "pass"] | |
>> h = {} | |
=> {} | |
>> a.each_with_index do |b, i| | |
?> h[i] = b | |
>> end | |
=> ["joe", "pass"] | |
>> h | |
=> {0=>"joe", 1=>"pass"} |
This file contains 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
## Listing | |
has_one :residential | |
delegate :room_desc | |
## Listing::Residential | |
## Console | |
>> listing.room_desc = "This is a room" | |
=> "This is a room" |
This file contains 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
ul | |
list-style-type: none | |
li | |
float: left |
OlderNewer