You are most likely going to have models. Those models are your
business objects. In your case you're not going to be talking to a
database, so the conventional "model" that is backed by a database
will not be needed.
However, a Model in Rails can just be a simple Ruby class. Typically
you'd have data models that did the RPC calls, so that the controllers
interacted with them. The models then do the RPC calls to your
backend, keeping each piece of code separated and easy to test. For
example, say you were making a new front-end to Twitter. A skeleton
model might look like this:
class Twitter
def initialize(user, password)
@user = user
@password = password
end
# returns timeline for the user
def posts
end
# creates a new post
def post(message)
....
end
private
end
Heck, you might even break this down farther and have a Post model,
which you'd use to hold the Post you retrieved from Twitter, or even
to have the Post class handle the creation of posts.
class Post
attr_accessor :message, :username, :posted_at
end
The basic idea here is that you'd use models to encapsulate your
logic, and controllers just to route requests around and show views.
So, you'll have "models". just not ActiveRecord models.
On Wed, Jan 21, 2009 at 7:30 AM, Shak <[email protected]> wrote:
>
> Hi,
>
> I'm looking into using RoR to develop a front end for an existing
> system - one which is accessible via JSON-RPC. As such, there won't be
> any data management performed directly by the web application itself,
> all would be done via these RPC calls.
>
> Is this possible? I assume that it is, so the next question is whether
> it's appropriate or not to chop off the model part of Rails. From
> tutorials and the like Rails seems quite dependent on convention (and
> even boasts of this). Will I get into trouble later on, or will
> decoupling the model part be more trouble than it's worth?
>
> Thanks,
>
> Shak
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---