I know i''m new with ruby and i''ve been kind of confused with
how rails
manages all the details. I want to store the key-values in different
columns on my database so that when I enter a eky, it gies me the
corresponding value. this is what i have:
my view:
<h1>Importing Strings<h1>
<%=error_messages_for("string_record")%>
<%= start_form_tag({:action => ''save''}, :multipart =>
true)%>
<p>
<b>Lenguage:</b><br/>
<%= select("variable", nil, @array_of_lenguages) %>
</p>
<p>
<b>Path: </b><br />
<%= file_field ("string_record", "import_strings"
)%>
</p>
<p><%= submit_tag "Import"%></p>
<%= end_form_tag%>
my save method in my controller:
def save
@string_record = StringRecord.new(params[:string_record])
if @string_record.save
redirect_to(:action=>''show'', :id =>@string_record.id)
else
render(:action=>:get)
end
end
this is my active record class:
class StringRecord < ActiveRecord::Base
def import_strings
table = { }
IO.foreach(''Localizable.strings'') { |line|
if line =~ /^ \s* " (.*?) " \s* = \s* " (.*?) "/x
table[ $1 ] = $2
end
table.eabh do |key, value|
string_record.create(:key => $1, :value => $2)
end
}
end
end
Can anybody help me out by guiding me in the right direction?
Any help will be highly appreciated.
rich
--
Posted via http://www.ruby-forum.com/.