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
| # Validations | |
| validates_presence_of :email, :unless => Proc.new { |user| user.email.blank? } | |
| validates_presence_of :username, :unless => :registered_with_email? | |
| def registered_with_username? | |
| self.username.blank? | |
| 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
| test "this is test 1" do | |
| assert true | |
| end | |
| test "this is test 2" do | |
| assert false | |
| 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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'open-uri' | |
| require 'nokogiri' | |
| require 'time' | |
| # ids of shows to check | |
| movie_ids = %w(tt0773262 tt0121955 tt0182576 tt0460649 tt0903747 tt0412142) |
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
| $device ||= Net::SSH::Telnet.new("Host" => "192.168.0.2", | |
| "Dump_log" => "dump_log3", | |
| "Username" => "admn", | |
| "Password" => "", | |
| "Timeout" => 60000, | |
| "Prompt" => /^CMD>$/) | |
| $device.cmd(params[:cmd]) {|c| $output << c} |
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
| device ||= Net::SSH::Telnet.new("Host" => "192.168.0.2", | |
| "Dump_log" => "dump_log3", | |
| "Username" => "admn", | |
| "Password" => "", | |
| "Timeout" => 60000, | |
| "Prompt" => /^CMD>$/) | |
| device.cmd(params[:cmd]) {|c| $output << c} |
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
| <%= form_for @user do |f| %> | |
| <%= f.fields_for :address do |address| %> | |
| <div class="field"> | |
| <%= address.label :street %><br /> | |
| <%= address.text_field :street %> | |
| </div> | |
| <% 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
| == MODEL == | |
| // do a check here to verify the requested subdomain is available | |
| def subdomain_is_unique | |
| business = Business.where( "lower(subdomain) = ?", subdomain.downcase ).first | |
| if !business.nil? | |
| errors.add( :subdomain, 'is already in use' ) | |
| else |
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
| class TopicAssociation < ActiveRecord::Base | |
| belongs_to :user | |
| belongs_to :topic | |
| after_create :calculate_popularity | |
| validates_uniqueness_of :user_id, :scope => :topic_id | |
| def calculate_popularity | |
| self.popularity = TopicAssociation.count(:all, :conditions=>{:topic_id => self.topic_id}) |
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
| require 'spec_helper' | |
| describe Bid do | |
| before(:each) do | |
| @user = Factory(:user) | |
| @user.funds = 10 | |
| @user.save() | |
| @prediction = Factory(:prediction) | |
| @attr= { | |
| :user_id => @user.id, |