Skip to content

Instantly share code, notes, and snippets.

@kevinpfromnm
kevinpfromnm / gist:3841138
Created October 5, 2012 17:22
full trace
/home/kevin/.rvm/gems/ruby-1.9.3-p0@hobo20/bundler/gems/hobo-645cb9c8e839/hobo/lib/hobo/extensions/enumerable.rb:5:in `block in group_by_with_metadata'
/home/kevin/.rvm/gems/ruby-1.9.3-p0@hobo20/bundler/gems/hobo-645cb9c8e839/hobo/lib/hobo/extensions/enumerable.rb:4:in `each'
/home/kevin/.rvm/gems/ruby-1.9.3-p0@hobo20/bundler/gems/hobo-645cb9c8e839/hobo/lib/hobo/extensions/enumerable.rb:4:in `group_by_with_metadata'
journey (1.0.4) lib/journey/gtg/builder.rb:28:in `transition_table'
journey (1.0.4) lib/journey/routes.rb:52:in `simulator'
journey (1.0.4) lib/journey/router.rb:112:in `simulator'
journey (1.0.4) lib/journey/router.rb:121:in `filter_routes'
journey (1.0.4) lib/journey/router.rb:128:in `find_routes'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:570:in `call'
@kevinpfromnm
kevinpfromnm / development.rb
Created October 5, 2012 16:45
dev environment
Foo::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
@kevinpfromnm
kevinpfromnm / gist:1157477
Created August 19, 2011 17:51
dryml tag wrapping for jquery accordion widget
<!-- Expects a hash: with keys for the accordion divisions -> values an option list appropriate for tag
default tag is select-one-radio for belongs_to and check-many for other contexts
example usage: <hjq-accordion options="&Location.all.group_by(&:country)" /> provides an accordion with
check-many checkboxes grouped by country name if the context is a has_many :locations, :through ... type
of association.
-->
<def tag="hjq-accordion" attrs="id, options, tag"><%
id ||= "accordion"
tag ||= if (refl = this_field_reflection)
if refl.macro == :belongs_to
@kevinpfromnm
kevinpfromnm / gist:1157385
Created August 19, 2011 17:18
radio button select one tag
<def tag="select-one-radio" attrs='include-none, blank-message, options, sort, limit, text-method'><%
raise Hobo::PermissionDeniedError.new("Not allowed to edit #{this_field}") if !attributes[:disabled] && !can_edit?
blank_message ||= ht("#{this_type.name.underscore}.messages.none", :default=>"No #{this_type.model_name.human} available.")
limit ||= 100
options ||= begin
conditions = ActiveRecord::Associations::BelongsToAssociation.new(this_parent, this_field_reflection).send(:conditions)
order = this_field_reflection.klass.default_order
this_field_reflection.klass.all(:conditions => conditions, :limit => limit, :order => order).select {|x| can_view?(x)}
end
@kevinpfromnm
kevinpfromnm / backtrace.log
Created August 8, 2011 18:06
polymorphic form error backtrace
ActionView::Template::Error (undefined method `default_order' for #<Class:0xb4dbc7ac>):
0 app/views/taglibs/auto/rapid/forms.dryml:6:in `form__for_comment'
app/views/taglibs/auto/rapid/forms.dryml:4:in `form__for_comment'
app/views/taglibs/auto/rapid/forms.dryml:4:in `form__for_comment'
app/views/taglibs/auto/rapid/forms.dryml:3:in `form__for_comment'
app/views/taglibs/application.dryml:18:in `show_page'
app/views/taglibs/application.dryml:14:in `show_page'
app/views/taglibs/application.dryml:14:in `show_page'
app/views/taglibs/application.dryml:13:in `show_page'
app/views/taglibs/auto/rapid/pages.dryml:220:in `show_page__for_post'
@kevinpfromnm
kevinpfromnm / picture.rb
Created June 30, 2011 04:39
example of s3 configured paperclip attachment
has_attached_file :image,
:styles => {
:original => ["1000x1000", :jpg ],
:medium => ["500x800", :jpg ],
:small => ["300x500", :jpg ],
:thumbnail => ["100x100#", :jpg ]
},
:default_style => :medium,
:storage => :s3,
:path => ":style/:id_:basename.:extension",
@kevinpfromnm
kevinpfromnm / controller.rb
Created June 29, 2011 04:12
example from tagglable hobo plugin (hobo 1.0.x)
autocomplete :new_tag_name do
post = find_instance
items = Tag.find(:all,:conditions => ['name LIKE ?',"%#{params[:query]}%"]).select { |i| i.viewable_by?(current_user) }
items = items - post.tags
render :text => "<ul>\n" +
items.map { |i| "<li>#{i.name}</li>\n" }.join +
"</ul>"
end
NoMethodError (undefined method `get_field_path' for Hobo:Module):
vendor/plugins/hobo/hobo/lib/hobo/hobo_helper.rb:245:in `can_view?'
vendor/plugins/hobo/hobo/taglibs/rapid_core.dryml:201:in `name'
vendor/plugins/hobo/dryml/lib/dryml/template_environment.rb:328:in `_tag_context'
vendor/plugins/hobo/dryml/lib/dryml/template_environment.rb:248:in `new_context'
vendor/plugins/hobo/dryml/lib/dryml/template_environment.rb:248:in `new_context'
vendor/plugins/hobo/dryml/lib/dryml/template_environment.rb:328:in `_tag_context'
vendor/plugins/hobo/hobo/taglibs/rapid_core.dryml:191:in `name'
app/views/taglibs/application.dryml:117:in `input__for_hobo_fields__markdown_string'
vendor/plugins/hobo/dryml/lib/dryml/template_environment.rb:328:in `_tag_context'
@kevinpfromnm
kevinpfromnm / comment.rb
Created January 19, 2011 23:34
Comments extract
class Comment < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
body :text, :required
timestamps
end
belongs_to :commentable, :polymorphic => true, :counter_cache => true
@kevinpfromnm
kevinpfromnm / comment.rb
Created January 11, 2011 00:11
Hobo model example
class Comment < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
body :text, :required
timestamps
end
belongs_to :commentable, :polymorphic => true, :counter_cache => true