Created
February 2, 2012 13:26
-
-
Save Amitesh/1723470 to your computer and use it in GitHub Desktop.
OpenStruct
This file contains hidden or 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 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