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 Assignment < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :role | |
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
@suggested_companies = [] | |
while @suggested_companies.count != 6 | |
@random_industry = Industry.first(:offset => rand(Industry.count)) # Industry.all.choice | |
@suggested_companies = AssociatedIndustry.where("source_type = 'Company' and industry_id = #{@random_industry.id}").limit(6).first.source # .collect(&:source) | |
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
def index | |
@industries=Industry.find(:all, :order=>"name asc") | |
render :layout=>'home_page' | |
end | |
Started GET "/" for 127.0.0.1 at 2013-11-19 12:21:30 +0000 | |
Processing by UserController#index as HTML | |
ActiveRecord::SessionStore::Session Load (0.3ms) SELECT `sessions`.* FROM `sessions` WHERE `sessions`.`session_id` = '4ed044611a37b2915a3259d0a6df3c85' AND `sessions`.`is_destroy` = 1 LIMIT 1 |
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 | |
def is_valid_isbn13?(isbn13) | |
sum = 0 | |
13.times { |i| sum += i.modulo(2)==0 ? isbn13[i].to_i : isbn13[i].to_i*3 } | |
0 == sum.modulo(10) | |
end | |
def isbn13_checksum(isbn12) | |
sum = 0 |