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 do_something_with_post(post) # what you write as (post) here is the same as |post| in a block | |
puts post | |
end | |
do_something_with_post(1) # will print 1 |
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
require 'rails' | |
require 'cucumber/rails3/application' | |
ENV["RAILS_ENV"] ||= "test" | |
require File.expand_path(File.dirname(__FILE__) + '/../../spec/dummy/config/environment') | |
require 'cucumber/rails3/action_controller' | |
if defined?(ActiveRecord::Base) |
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
I have a session variable that is created on login called current_user i can access the company id and user id by calling the following: current_user.company_id and current_user.id |
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
# this one does NOT work | |
params[:wine] = {:bulk_price_per_dozen => 50} | |
@wine = Wine.new(params[:wine]) | |
# this one ALSO does NOT work | |
@wine = current_seller.wines.build(params[:wine]) | |
# this one does work | |
@wine = current_seller.wines.build | |
@wine.attributes = params[:wine] |
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(@user) do |f| %> | |
<% if @user.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2> | |
<ul> | |
<% @user.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> |
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
# encoding: utf-8 | |
require "json" | |
# Expected (and MRI behavior): | |
str = JSON.parse('{"a":"\u00f8"}')["a"] | |
str == "ø" | |
str.encoding.to_s == "UTF-8" | |
# Actual (jruby behavior): |
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
%w(action_controller/railtie).map &method(:require) | |
run JrubyRackTest ||= Class.new(Rails::Application) { | |
config.secret_token = routes.append { root to: 'send_file#deliver' }.inspect | |
initialize! | |
} | |
class SendFileController < ActionController::Base | |
def deliver | |
send_file Rails.root.join("testdata.jpeg") |
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
object with tag: 10 and value: 2 and val.class: org.jruby.RubyFixnum and impl: org.bouncycastle.asn1.DEREnumerated | |
WARNING: unimplemented method called: asn1data#toASN1 |
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
require 'openssl' | |
blk = "0)\x02\x01\x01`$\x02\x01\x03\x04\x17cn=admin,dc=test,dc=com\x80\x06secret" | |
asn1 = OpenSSL::ASN1::decode(blk) | |
protocolOp = asn1.value[1] | |
puts protocolOp.inspect |
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
ActionView::Template::Error (Java heap space): | |
java.nio.HeapCharBuffer.<init>(HeapCharBuffer.java:39) | |
java.nio.CharBuffer.allocate(CharBuffer.java:312) | |
java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:775) | |
java.nio.charset.Charset.decode(Charset.java:771) | |
org.jruby.RubyEncoding$UTF8Coder.decode(RubyEncoding.java:246) | |
org.jruby.RubyEncoding.decodeUTF8(RubyEncoding.java:192) | |
org.jruby.RubyString.decodeString(RubyString.java:719) | |
org.jruby.RubyString.toString(RubyString.java:701) | |
org.jruby.RubyNameError$RubyNameErrorMessage.to_str(RubyNameError.java:120) |
OlderNewer