Skip to content

Instantly share code, notes, and snippets.

>> Company.authenticate("luke", "force")
~ SELECT "crypted_password", "salt", "id", "login", "email", "name", "first_name", "last_name", "street", "postcode", "city", "phone", "www", "rank", "trade_id", "type", "created_at", "updated_at", "activated_at", "activation_code" FROM "users" WHERE ("type" IN ('Company')) AND ("login" = 'luke') ORDER BY "id" LIMIT 1
=> nil
>> Person.authenticate("luke", "force")
~ SELECT "crypted_password", "salt", "id", "login", "email", "name", "first_name", "last_name", "street", "postcode", "city", "phone", "www", "rank", "trade_id", "type", "created_at", "updated_at", "activated_at", "activation_code" FROM "users" WHERE ("type" IN ('Person')) AND ("login" = 'luke') ORDER BY "id" LIMIT 1
=> #<Person crypted_password="7ca275efcc90584839d5ae66ac5aae3475c5572d" salt="e39c0adcfae0c5767b849c7f4381de5387757565" id=4 login="luke" email="luke@force.com" name="Luke Skywalker" first_name="Luke" last_name="Skywalker" street=nil postcode=nil city=nil phone=nil www=nil rank=nil trade_i
@n, @k = 18, 6
def f(start, curr)
if curr.size == @k
puts curr.inspect
else
((start+1)..@n).each do |b|
f(b, curr + [b])
end
end
end
def save_2
save
end
after :save, :update_opinions_rank
def update_opinions_rank
raise
end
[15:26:03][ teamon ~/rails_apps/ps12 ] merb
Loading init file from /private/RAILS/teamon/ps12/config/init.rb
Loading /private/RAILS/teamon/ps12/config/environments/development.rb
sh: /usr/bin/gcc: Brak dostępu
/usr/local/lib/ruby/gems/1.8/gems/RubyInline-3.8.1/lib/inline.rb:589:in `build': error executing "gcc -m32 -march=athlon -shared -Werror -fPIC -m32 -march=athlon -fPIC -I /usr/local/lib/ruby/1.8/x86_64-linux -I /usr/local/include -L/usr/local/lib -o \"/home/teamon/.ruby_inline/Inline_RawParseTree_ab80.so\" \"/home/teamon/.ruby_inline/Inline_RawParseTree_ab80.c\" ": 32256 (CompilationError)
Renamed /home/teamon/.ruby_inline/Inline_RawParseTree_ab80.c to /home/teamon/.ruby_inline/Inline_RawParseTree_ab80.c.bad from /usr/local/lib/ruby/gems/1.8/gems/RubyInline-3.8.1/lib/inline.rb:819:in `inline'
from /usr/local/lib/ruby/gems/1.8/gems/ParseTree-3.0.2/lib/parse_tree.rb:250
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/si
[15:30:22][ teamon ~/rails_apps ] merb-gen app test
Generating with app generator:
[ADDED] Rakefile
[ADDED] app/controllers/application.rb
[ADDED] app/controllers/exceptions.rb
[ADDED] app/models/user.rb
[ADDED] app/helpers/global_helpers.rb
[ADDED] app/views/exceptions/not_acceptable.html.erb
[ADDED] app/views/exceptions/not_found.html.erb
[ADDED] autotest/discover.rb
>> Company.get(2)
~ SELECT "crypted_password", "salt", "id", "login", "email", "name", "first_name", "last_name", "street", "postcode", "city", "phone", "www", "rank", "trade_id", "type", "created_at", "updated_at", "activated_at", "activation_code" FROM "users" WHERE ("type" IN ('Company')) AND ("id" = 2) ORDER BY "id" LIMIT 1
=> #<Company crypted_password="1a8b2b488675e071877f48301b02e234c9026f5b" salt="ab2a0c734c196ade7f75ac5a4a1fbf22a083c4d6" id=2 login="empire" email="empire@teamon.eu" name="Dark Empire" first_name=nil last_name=nil street="" postcode="" city="" phone="" www="" rank=25 trade_id=3 type=Company created_at=#<DateTime: 10604656033/4320,1/24,2299161> updated_at=#<DateTime: 21209317139/8640,1/24,2299161> activated_at=#<DateTime: 10604656033/4320,1/24,2299161> activation_code=nil>
>> Company.get(2).update_attributes(:rank => 1)
~ SELECT "crypted_password", "salt", "id", "login", "email", "name", "first_name", "last_name", "street", "postcode", "city", "phone", "www", "rank", "trade_id", "
def update_rank
# Merb.logger.my_debug products.map{|e| e.id}.inspect
# Merb.logger.my_debug products.opinions.accepted.map{|e| e.rank}.inspect
# self.rank = products.opinions.accepted.sum(:rank)
#self.rank =
products #.opinions.accepted.sum(:rank)
Merb.logger.my_debug "rank #{rank}"
# Merb.logger.my_debug("updating owner")
save
Merb.logger.my_debug("owner updated")
%w(text_field password_field hidden_field file_field
text_area select check_box radio_button radio_group).each do |kind|
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def labeled_#{kind}(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
options[:label] = args.first.to_s.gsub('_', ' ').capitalize.t + ":" unless options[:label]
args.push(options)
#{kind}(*args)
end
class Default < Application
def index
render :text => "index"
end
def admin_login
render :text => "dziala"
end
end
= fieldset :legend => "Images:" do
- @product.max_attachments_size.times do |i|
%p
- if a = @product.attachments[i]
= file_field :name => "product[attachments][#{a.id}][data]", :label => a.filename
= check_box :name => "product[attachments][#{a.id}][delete]", :label => "Delete?".t
- else
= file_field :name => "product[attachments][new][]", :label => "Image %d:".t(i+1)