Skip to content

Instantly share code, notes, and snippets.

<% cat_opts = [] %>
<% Category.all.each do |c| %>
<% cat_opts << [c.name, c.id] %>
<% end %>
<%= f.select :category_id, cat_opts %>
<%= f.select :category_id, Category.all.map{ |c| [c.name, c.id] } %>
# in spec_helper.rb
config.mock_with :mocha
#...
end
# returns current fake user
def current_user
@current_user ||= User.make
%tr.fields
%td
= f.collection_select :product_id, Product.all, :id, :name
%td#price_unit
:javascript
$(function (){
new_id = $("#price_unit").prev("td").next("select").attr("class");
alert(new_id);
});
files = Dir.glob('dir/**/*')
output_to = File.open('result.txt', 'w')
for file in files
if file =~ /(rb|haml)$/ and !(file =~ /plugins/)
output_to.write "# FAILAS: #{file}"
output_to.write "\n"
output_to.write(File.read(file))
output_to.write "\n"
f = File.read("9niwrHXd.txt")
f.split("<url>").each do |e|
f.gsub!(e, '') if e =~ /aspx\?/
end
f.gsub!(/(<url>){2,}/, "<url>")
File.open("new.txt", "w") do |n|
n.write f
end
vidmantas@samesystem:~/projects/same3$ script/server
/usr/local/lib/ruby/1.9.1/date/format.rb:8: warning: already initialized constant MONTHS
/usr/local/lib/ruby/1.9.1/date/format.rb:14: warning: already initialized constant DAYS
/usr/local/lib/ruby/1.9.1/date/format.rb:19: warning: already initialized constant ABBR_MONTHS
/usr/local/lib/ruby/1.9.1/date/format.rb:25: warning: already initialized constant ABBR_DAYS
/usr/local/lib/ruby/1.9.1/date/format.rb:30: warning: already initialized constant ZONES
/usr/local/lib/ruby/1.9.1/date.rb:236: warning: already initialized constant MONTHNAMES
/usr/local/lib/ruby/1.9.1/date.rb:242: warning: already initialized constant DAYNAMES
/usr/local/lib/ruby/1.9.1/date.rb:245: warning: already initialized constant ABBR_MONTHNAMES
/usr/local/lib/ruby/1.9.1/date.rb:249: warning: already initialized constant ABBR_DAYNAMES
Processing MessagesController#index (for 127.0.0.1 at 2010-09-06 14:40:50) [GET]
Parameters: {"controller"=>"messages", "action"=>"index"}
Psych::SyntaxError (couldn't parse YAML at line 21 column 14):
/home/vidmantas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/psych.rb:148:in `parse'
/home/vidmantas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/psych.rb:148:in `parse_stream'
/home/vidmantas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/psych.rb:119:in `parse'
/home/vidmantas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/psych.rb:106:in `load'
config/initializers/localization.rb:25:in `translate'
app/models/user.rb:133:in `<class:User>'
Processing Schedule::CalendarController#confirm_date (for 127.0.0.1 at 2010-09-06 14:54:03) [POST]
Parameters: {"{\"confirm\": true, \"date\": \"2010-05-18\", \"user_ids\": "=>{"3, 4, 14124, 1, 2"=>{", \"shop_id\": 1, \"pp\": 2639}"=>nil}}, "controller"=>"schedule/calendar", "action"=>"confirm_date", "ctx_token"=>"c1d1"}
User Columns (4.7ms) SHOW FIELDS FROM `users`
User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 5) LIMIT 1
User: 5, ctx_token: c1d1, path /c1d1/schedule/calendar/confirm_date
Client Columns (0.8ms) SHOW FIELDS FROM `clients`
Client Load (0.1ms) SELECT * FROM `clients` WHERE (`clients`.`id` = 1)
Role Columns (0.6ms) SHOW FIELDS FROM `roles`
Role Load (0.1ms) SELECT * FROM `roles` WHERE (`roles`.`id` = 192)
Shop Columns (0.7ms) SHOW FIELDS FROM `shops`
$ rake jobs:work --trace
(in /home/vidmantas/projects/same3)
** Invoke jobs:work (first_time)
** Invoke merb_env (first_time)
** Execute merb_env
** Invoke environment (first_time)
** Execute environment
** Execute jobs:work
[Worker(host:samesystem pid:10185)] Starting job worker
rake aborted!
remi@samesystem1:/var/www/samesystem$ RAILS_ENV=production rake jobs:work
(in /var/www/samesystem)
Booting Rails... (0.41s)
[Worker(host:samesystem1 pid:1714)] Starting job worker
rake aborted!
undefined class/module Context
/opt/ruby-1.9.2/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:251:in `path2class'
/opt/ruby-1.9.2/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:251:in `resolve_class'
/opt/ruby-1.9.2/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:180:in `visit_Psych_Nodes_Mapping'
/opt/ruby-1.9.2/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept'