Newbie question - Rails without database

Hello to all,

I am entirely new to Ruby and also to Ruby on Rails. As far as I
understand,
Rails builds its model according to the a specified table structuree in
in the
database.

However, most of my applications, are for the most part (except some
backend
CRUD stuff) not database centric. They do a lot of calculation for the
user.

So, how can I create a model, when no database is needed, and yet, have
it
running on the Rails framework?

Greetings

Michael K.

You pretty much inferred your own answer - you don’t need a model. JUst
create a controller to do the math and a view to display.

Geoff

Well, I wasn’t very specific.

actually, what I mean is a very simple two step workflow.

The user is requierd to fill in a form with a number of fields. After he
has
submitted the form, the data is being evaluated.

If errors occur the user is returned to the initial form. Otherwise he
proceeds
to the next form, where he is once again required to enter some more
data,
depending on the result.

And then the final calculation step, again with some calculation, takes
place.

For the duration of the session, there is a model on the web server for
backing
up of the form data.

Eventually the resulting data is being processed for pdf generation. But
there’s
no persistence taking place.

Is there a way Rails can still automatically match my form data with the
model
and evaluate it?

Sincerely

Michael K.

On 3/16/06, Michael K. [email protected] wrote:

So, how can I create a model, when no database is needed, and yet, have it
running on the Rails framework?

Just try creating your model classes by hand, instead of using the
`generate’ script. Rails can do some object-relational mapping work
for you if a database is in use, but if you don’t need one, you can
choose not to use it. Just make sure to not subclass
ActiveRecord::Base on your model classes.

Cheers,

Thiago A.

Thiago A. wrote:

On 3/16/06, Michael K. [email protected] wrote:

So, how can I create a model, when no database is needed, and yet, have it
running on the Rails framework?

Just try creating your model classes by hand, instead of using the
`generate’ script. Rails can do some object-relational mapping work
for you if a database is in use, but if you don’t need one, you can
choose not to use it. Just make sure to not subclass
ActiveRecord::Base on your model classes.

Cheers,

Thiago A.

…took a long time to reply to this message, but as i am working on
something simillar to this, i was hoping to see if someone can give me a
little more informative(for a newbie, yea) information as to using a
rails app without a database (i need to build a model, and i was told
not to use activerecord, but from there on, i am in the dark…)
any help, links, or just general sympathy will be mostly appreciated.

with much thanks,

shai rosenfeld
newbee employee for Octava IL

Hi Shai,

General sympathy :slight_smile:

Seriously, you’ll have to give more details as to what you want to
acheive before anyone can help. For example, when you said you need to
have a model but don’t want to use a database, what do you mean by that?
How do you want to persist your model? If you don’t want to persist your
model, then just create any Ruby class, and there you have it. Nothing
fancy needed. If you want to persist it to the file system, then YAML it
or work a bit harder to XML it.

shai wrote:

choose not to use it. Just make sure to not subclass
little more informative(for a newbie, yea) information as to using a
rails app without a database (i need to build a model, and i was told
not to use activerecord, but from there on, i am in the dark…)
any help, links, or just general sympathy will be mostly appreciated.

with much thanks,

shai rosenfeld
newbee employee for Octava IL


Sau S.

http://blog.saush.com
http://www.projectible.com
http://jaccal.sourceforge.net

Hi,

I think you could use the “session” valiable. Basically, it’s a cookie
where
you can store specific user info - without actually identifying the
user.

“session” is a hash table, therefore it seems to make sense to create
session[:page_1] = Array.new(), and then to store your questions in this
array. You do the same for page 2 and so on.
It could be wiser to create a Hash.new() instead of the Array, becaus
you
could insert “meaningful” data, for example a field “valid”. In that
case,
you would store the answers like:

session[:page_1][:question_1] = @params[:question_1]

(if everything OK)
session[:page_1][:valid] = true

then you render page 2. When a page is rendered, you take the answers
from
the session valiable, and you are able to go back / forward / repeat
while
keeping the values set by the user.

Yu can also remember which page you render, and in that case you
prpobably
need only one controller to handle everything (but that’s an other
story)

Regards

Nicolas