Need some super-noob help with some concepts

Hello all! I’m new to actually building anything with these little
fragments of programming knowledge that I cobbled together, so I’m
hoping
someone can give me a push in the right direction.

I’m working on building a ‘utility’ rails site that will only be used by
myself and one or two coworkers. I’m not concerned with security (it
will
be a local webserver only), appearance, etc. I just need one thing to
work. The plan is this:

I have remote jobsites that will report back to our server via a small
ftp
file. For now it will just send us their WAN IP, but I plan on expanding
this once I figure out the overall structure of what the heck I’m trying
to
do. :slight_smile: I want to be able to go to the local Rails webserver and see a
list
of all our jobsites with a list of their WAN IPs and last updated times.

So… I have the FTP side working. I have the rudimentary Rails ‘site’
working, and I can manually enter jobsite info at the
localhost:3000/sites
URL. I need to automate the process of parsing each FTP file and adding
it
to the database. The parsing I can work out, but I am clueless on how
to
even begin updating this ‘app’ from a script that is ‘outside’ of the
Rails
app…if that makes sense.

I can run a script that parses the FTP file, but what approach do I take
to
get the parsed info INTO the database?

There are probably 100 ways to do this and I know 0 of them. :slight_smile:

Thanks!
Jim S

( the issue I’m having right now is that since I don’t even know what
concept to use, I have to research different ways to do ‘it’, then I
have
to learn how to do ‘it #1’, then I go off on that tangent for a while,
figure out it’s not what I want, go back to researching other methods,
then
have to learn how to do ‘it #2’, go off in that direction for a while,
etc.
I can tell you that I’ve learned more USEFUL programming knowledge over
the past month now that I have something to work on than I have in the
past
2 years doing random online tutorials and classes and having no
real-world
application for it… )

On 8 December 2012 02:57, Jim S. [email protected]
wrote:

file. For now it will just send us their WAN IP, but I plan on expanding

I can run a script that parses the FTP file, but what approach do I take to
get the parsed info INTO the database?

There are probably 100 ways to do this and I know 0 of them. :slight_smile:

You could run a Rake task to update the db. The proper way to do this
would be to write a rake task, but the easiest way to get going would
be to use the provided rake task db:seed. This runs the file
db/seeds.rb in the context of the application, so that all the
ActiveRecord stuff is automatically available. To run the rake task
you just
cd /path/to/rails/application
rake db:seed
or if you want it to run on the production db
RAILS_ENV=production rake db:seed
which could be run from a cron task or whatever is appropriate.

So all you need do is to put your code in db/seeds.rb and you will be
up and running.

Colin