Skip to content

Instantly share code, notes, and snippets.

@Amitesh
Created February 2, 2012 13:26
Show Gist options
  • Save Amitesh/1723470 to your computer and use it in GitHub Desktop.
Save Amitesh/1723470 to your computer and use it in GitHub Desktop.
OpenStruct
<%= 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