Forum: Ruby on Rails Newbie question - Rails without database

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2ba0ca567353a0b1c28cfc0b5b341ef2?d=identicon&s=25 Michael Kastner (Guest)
on 2006-03-16 10:02
(Received via mailing list)
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 Kastner
29c5380dd7c19eebebf03bc050c7e27d?d=identicon&s=25 Geoff Hopson (Guest)
on 2006-03-16 10:08
(Received via mailing list)
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
2ba0ca567353a0b1c28cfc0b5b341ef2?d=identicon&s=25 Michael Kastner (Guest)
on 2006-03-16 10:33
(Received via mailing list)
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 Kastner
B1d59a804bd67487c964bc505a8eb892?d=identicon&s=25 Thiago Arrais (Guest)
on 2006-03-16 12:59
(Received via mailing list)
On 3/16/06, Michael Kastner <kastner@galt.de> 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 Arrais
Ce953bec3af375ddc75e375233112b28?d=identicon&s=25 shai (Guest)
on 2006-05-18 14:36
Thiago Arrais wrote:
> On 3/16/06, Michael Kastner <kastner@galt.de> 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 Arrais


...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
D2a5b7975f49e051c1de10f98ea81f63?d=identicon&s=25 Chang Sau Sheong (Guest)
on 2006-05-18 14:58
(Received via mailing list)
Hi Shai,

General sympathy :)

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 Sheong

http://blog.saush.com
http://www.projectible.com
http://jaccal.sourceforge.net
C29d9db03853958c4de5ee6b06edd39a?d=identicon&s=25 Nicolas Buet (Guest)
on 2006-05-18 16:43
(Received via mailing list)
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
This topic is locked and can not be replied to.