Topic: form_for for a hash instead of model?
My site configuration is stored in a YAML file. The user edits this file via a form on the site. Here's how the form looks:
<% form_tag :action => 'config', :method => :post do %>
<%= text_field 'settings', 'support_email', :size => 20, :value => @hashish['support_email']%>
<%= radio_button 'settings', 'allow_comments', 1, :checked => (@hashish['allow_comments']==1) %>
<%= radio_button 'settings', 'allow_comments', 0, :checked => (@hashish['allow_comments']==0) %>
<% end %>
@hashish was set in the controller: @hashish = YAML.load_file("blah.yml")
This works perfectly, but I have a gut feeling that Rails contains an elegant way of handling this situation?
Edit: While on this topic, where is the best place to put the settings hash? I want it loaded on startup and to just remain in memory because it will be accessed throughout the entire app (views, controllers)
Last edited by Relax (2008-01-05 21:02:16)