what the recommended way to generate static html files based on a database structure, for example 1000 product pages.

i would like to specify s template and embed css styles.

i use rails 3.1

thanx

--
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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Daniel Nachbar at Sep 19, 2011 at 10:09 pm

    On Sep 19, 2:10 pm, "Jochen Kächelin - 8frogs.de" wrote:
    what the recommended way to generate static html files based on a database structure, for example 1000 product pages.

    i would like to specify s template and embed css styles.

    i use rails 3.1

    thanx
    I'd look into using factory girl.

    http://rubygems.org/gems/factory_girl

    Dan Nachbar

    --
    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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • 7stud -- at Sep 19, 2011 at 10:56 pm
    "\"Jochen Kächelin - 8frogs.de\"" <info@8frogs.de> wrote in post
    #1022809:
    what the recommended way to generate static html files based on a
    database structure, for example 1000 product pages.

    i would like to specify s template and embed css styles.

    i use rails 3.1

    thanx
    erb templates are part of the ruby language, as is the ability to query
    a database. So you can write a ruby program that creates an erb
    template, and you can query the database to fill in values in the
    template, and then write the results to a bunch of files.

    --
    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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • 7stud -- at Sep 20, 2011 at 12:07 am
    Here is an example:

    require 'erb'
    require 'sqlite3'

    template = ERB.new <<"END_OF_TEMPLATE"
    <html>
    <head>
    <title><%= name %></title>
    <style type="text/css">
    div {color:blue;}
    </style>
    </head>
    <body>
    <div>Name: <%= name %></div>
    <div>Color: <%= color %></div>
    </body>
    </html>
    END_OF_TEMPLATE

    db = SQLite3::Database.new( "my_db.db" )
    table = "test"


    db.execute( "select * from #{table}" ) do |row|
    name, color = row

    File.open("#{name}.html", "w") do |f|
    f.puts template.result(binding)
    #binding gathers up the variables and their values

    end

    end

    --output:--

    hammer.html:

    <html>
    <head>
    <title>hammer</title>
    <style type="text/css">
    div {color:blue;}
    </style>
    </head>
    <body>
    <div>Name: hammer</div>
    <div>Color: black</div>
    </body>
    </html>

    --
    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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedSep 19, '11 at 9:50p
activeSep 20, '11 at 12:07a
posts4
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase