If you''re new to the world of web development, it might help to have a
bit
of context on what Camping''s "models" actually are.
ActiveRecord is an
abstraction of a database that''s primarily developed for use in the
Ruby on
Rails framework, which you could argue Camping is to some extent a
rebellion against.
In early web apps, people would manually embed SQL query strings in scripts
and templates written for PHP, Perl, Python, etc. This approach has several
problems, possibly most importantly: it''s difficult to
"scale" the
functionality of a web app or make it more interactive, and it''s
vulnerable
to attacks like "SQL" injection, where malicious input can have an
undesirable effect on server-side behaviour.
Most popular web frameworks use something called an "ORM", which is
what
ActiveRecord is - the data in the database is represented via
"classes" and
native objects in the code. Camping is somewhat uncommon as a lightweight,
beginner-friendly framework that has a built-in ORM (though there''s
nothing
forcing you from using its neat rendering and routing features without
bothering with the Models, or from implementing your own "Models" atop
files or a noSQL database.
On Sep 6, 2012 8:21 PM, "Dave Everitt" <deveritt at
innotts.co.uk> wrote:
> Hi Cj
>
> I don''t think anyone answered your question, so here''s a
quick reply.
> Since you said "I''m not sure I understand what models
do" I presume you''re
> a beginner, so this states what may already be obvious! I''m still
a noob at
> heart too.
>
> You don''t really need a models module to do what your little app
does -
> there''s not enough data to warrant it. Here''s the Camping
intro to models:
> http://camping.io/Book/-Getting-Started#Modeling-the-world
>
> Basically, you''d use models when constructing an app that needs a
database
> - take a look at the models module in the Camping blog example (
> https://github.com/camping/camping/blob/master/examples/blog.rb)
>
> By default, models use ActiveRecord (with a Ruby-friendly syntax) to
> create and manage the database (SQLite is the Camping default).
>
> DaveE
>
> Hello,
> I''m new to ruby and camping. I''m learning ralis along
with camping. I like
> camping because the MVC is all on one page.
> So, I''m wondering if you can help.
> Here''s my code. <https://gist.github.com/3562873>
> I''m writing a little app that displays a random quote when you
refresh the
> page.
> On line 30 and 31 I have an array and show the index page and sample the
> array.
>
> So, guide me on how to put this in the model module. But I''m not
sure I
> understand what models do. Told you I''m a noob!
> Thanks in advance for your help.
>
> Cj.
> _______________________________________________
> Camping-list mailing list
> Camping-list at rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
>
>
> _______________________________________________
> Camping-list mailing list
> Camping-list at rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/camping-list/attachments/20120906/5bc6de6d/attachment.html>