Hi all,
(I’m new with RoR) I’m using a migratio to import data into a database
but nothing is being happens. I’m importing strings from a parsed file.
this is what I have:
controller:
class UploadController < ApplicationController
def create
table = { }
params[:localized_string][:data].each_line do |line|
if line =~ /^\s* " (.?) " \s = \s* " (.*?) "/x
table[$1] = $2
end
end
table.each do |key, val|
LocalizedString.save(:key =>key, :value=> val)
end
end
end
model:
class LocalizedString < ActiveRecord::Base
end
view:
Importing Strings
<%= start_form_tag({:action => 'create'}, :multipart => true)%>
Path:
<%= file_field ("localized_string", "data" )%>
<%= submit_tag "Import"%>
<%= end_form_tag%>
The table does get mapped on the database but no data gets imported.
I’m wondering if I’m missing something in the model…can anybody help
me out? I’ll appreciate your help.