Parsing data and create record when app starts

Hello, I'm a newbie and would be appreciated for any help.

So that's the situation: I try to build a simple rails app which will give users an opportunity to manage a list of some product. But except creating by user, some products list should be loaded into the view when app starts. This list is produced by parsing information from a web-site. I've already write a ruby script which collects the data and push it into "Product" object.

And now, how to implement that in rails app enviroment? Here I have "Product" model with the required parameters, but where I should implement initial creating these products (when app starts) to see them at the view? Something like that:

=========== some_file.rb(model?conroller?) ===========

def pull_data(WEBSITE_URL) ... # parsing data into initial_products array ... # creating new records according to the parsed objects   initial_products.each do |p|      Product.new(p.field1, p.field2, ...)   end ... end

============== product.rb ==============

class Product < ActiveRecord::Base   attr_accessible %list of parameters% end

products list should be loaded into the view when app starts.

In Rails, apps don't start. Instead, web browsers send requests to urls, which your app then directs to the proper controller and action. So I would start by reading the Rails Guide about routing to figure out how to write simple routes. Then you can route a chosen url to a certain controller in your app and to a certain action in that controller. The action can then provide the data that the view will display, i.e. your Products.

Hmm, I think I get it. Thanks.

And now it works just as I planned.