Skip to content

Instantly share code, notes, and snippets.

@flakd
Forked from Amitesh/gist:1723470
Created July 3, 2013 06:18
Show Gist options
  • Select an option

  • Save flakd/5915812 to your computer and use it in GitHub Desktop.

Select an option

Save flakd/5915812 to your computer and use it in GitHub Desktop.
<%= form_for OpenStruct.new(:message => ''), :url => ... do |f| %>
<%= f.text_field :message %>
<% end %>
# config/initializers/open_struct_extensions.rb
class OpenStruct
def respond_to?(symbol, include_private = false)
true
end
end
# Create object through OpenStruct
require "ostruct"
App = OpenStruct.new({
:name => "Amitesh",
:friend => OpenStruct.new({
:name => "dexter"
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment