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. :) 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. :) 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... ) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/89zziTO2VwYJ. For more options, visit https://groups.google.com/groups/opt_out.
On 8 December 2012 02:57, Jim Stolzenbach <jkstolzenbach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. :) 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. :)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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.