Newbie--how do i load a parsed file?

Hello there,

I’m new with ruby on rails and i don’t know how to load up a parsed file
into my database. I have my ruby script that parses it but don’t know
where to put my code, or how to combine it with view/model/controller.
this is what i have:

class Description < ActiveRecord::Base

def import_strings(a_file)
table = { }
IO.foreach(’#{a_file}’) { |line|
if line =~ /^ \s* " (.?) " \s = \s* " (.*?) "/x
table[ $1 ] = $2

description =
description.Lenguage = [$1]
description.Platform = [$2]



My view:

Importing Strings

<%= start_form_tag({:action => ‘save’}, :multipart => true)%>


<%= select(“variable”, nil, @array_of_lenguages) %>


<%= file_field (“description”, “description”

<%= submit_tag “Import”%>

<%= end_form_tag%>

I only get the actual displays but the file is never loaded into the
database. Does anybody know why?

Any help is apreciated

For starters, your form tag points at an action called ‘save’, and all
code is in an action called ‘import_strings’. Unless you left some other
code out, your method won’t be called by this form.

Also I don’t think you’re quite understanding what will come in from
form field parameter. Might want to have a look at:


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs