html - Ruby + ActiveRecord: Reading from the Database -


i've written ruby script parses tab-delimited text file , writes output sqlite3 database activerecord. next, need write ruby script display database's contents static html.

the text file i'm working list of parts company has sale. database has 1 table; each row in database different part, , each column different attribute of part (i.e., size, weight, list price, , on , forth). need able sort table "short description" column in alphabetical order, output each row series of html tables.

i've got no idea next. i've been working ruby 2 weeks, , i've been using activerecord 4 days, i'm little lost. i've been googling answer morning, i've not found i'm wanting do.

here's copy of sqlite3 table declaration, if it's help:

create table parts_info(item_number integer primary key asc, location text,  quantity integer, make text, year integer, model text, serial text, volt integer,  phase integer, weight integer, list_price real, sold integer,  image_path text, short_desc text, long_desc text, junk text); 

it may i'm approaching wrong angle, , if that's case, open suggestions how better.

the idea activerecord have model represents row in table, , activerecord automatically maps data database instances of object, , vice versa.

so, create html table, want retrieve list of partsinfo objects, , convert them html. there number of options that: may want use erb template file turn object desired html. might want @ builder gem.

edited add: list of objects, use activerecord query methods. e.g. partsinfo.all.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -