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
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 On 16/03/06, Michael Kastner <kastner@galt.de> wrote:> > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060316/fb0fb427/attachment.html
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 Geoff Hopson wrote:> 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 > > On 16/03/06, * Michael Kastner* <kastner@galt.de > <mailto:kastner@galt.de>> wrote: > > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org <mailto:Rails@lists.rubyonrails.org> > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
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
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 -- Posted via http://www.ruby-forum.com/.
Chang Sau Sheong
2006-May-18 12:56 UTC
[Rails] Re: Newbie question - Rails without database
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:> 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 > >-- Sau Sheong http://blog.saush.com http://www.projectible.com http://jaccal.sourceforge.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060518/a379cc2d/attachment.html
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 On 3/16/06, Michael Kastner <kastner@galt.de> wrote:> > 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 > > > Geoff Hopson wrote: > > 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 > > > > On 16/03/06, * Michael Kastner* <kastner@galt.de > > <mailto:kastner@galt.de>> wrote: > > > > 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 > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org <mailto:Rails@lists.rubyonrails.org> > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060518/f0289281/attachment.html