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
--
Posted via http://www.ruby-forum.com/.
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment