Discussion:
Using Fog in Rails Model - Design Question
JayP
2012-11-08 02:53:52 UTC
Permalink
Hi,

I am thinking of writing a rails app that interacts with the cloud and
wanted to use Fog as my client library to aws. To start I plan on doing
all the fog api calls in my models. To start I want to be able to CRUD
launch configurations so ActiveModel looks like a good place to start.
Going down this path though I'm having some design issues where when I
fetch a launch configuration using the "get" method I get
a Fog::AWS::AutoScaling::Configuration object back. I could pass this all
the way to the controller then up to the view so it has access to all the
attributes on the object but that seems weird to me since my model is
called LaunchConfiguration but the object returned from my model would be
of type Fog::AWS::AutoScaling::Configuration. If I want to create a new
model based off of everything in the returned object I could do that but it
seems like I would just be repeating everything that comes back from the
fog library but maybe this is the best approach. So my question is what
approach would you take if you were designing something like this.

Thanks in advance,
Jay
JayP
2012-11-09 01:03:48 UTC
Permalink
Just to give this an update, I ended up bridging the fog library to each
model in my application. For example AutoScalingGroup (Model) =>
Fog::AWS::AutoScaleGroup. I create a new AutoScalingGroup instance for
each object I get back from fog. This allows my controllers to fetch my
model objects rather than fog's objects. I used ActiveModel for all of
this and everything seems to work well. I'm still interested though if
others had any other ideas.

Thanks,
Jay
Post by JayP
Hi,
I am thinking of writing a rails app that interacts with the cloud and
wanted to use Fog as my client library to aws. To start I plan on doing
all the fog api calls in my models. To start I want to be able to CRUD
launch configurations so ActiveModel looks like a good place to start.
Going down this path though I'm having some design issues where when I
fetch a launch configuration using the "get" method I get
a Fog::AWS::AutoScaling::Configuration object back. I could pass this all
the way to the controller then up to the view so it has access to all the
attributes on the object but that seems weird to me since my model is
called LaunchConfiguration but the object returned from my model would be
of type Fog::AWS::AutoScaling::Configuration. If I want to create a new
model based off of everything in the returned object I could do that but it
seems like I would just be repeating everything that comes back from the
fog library but maybe this is the best approach. So my question is what
approach would you take if you were designing something like this.
Thanks in advance,
Jay
geemus (Wesley Beary)
2012-11-12 16:04:09 UTC
Permalink
That sounds like a pretty good approach, thanks for sharing. I'd love to
offer counter points but I haven't coded models in other systems for this
in a while.
Post by JayP
Just to give this an update, I ended up bridging the fog library to each
model in my application. For example AutoScalingGroup (Model) =>
Fog::AWS::AutoScaleGroup. I create a new AutoScalingGroup instance for
each object I get back from fog. This allows my controllers to fetch my
model objects rather than fog's objects. I used ActiveModel for all of
this and everything seems to work well. I'm still interested though if
others had any other ideas.
Thanks,
Jay
Post by JayP
Hi,
I am thinking of writing a rails app that interacts with the cloud and
wanted to use Fog as my client library to aws. To start I plan on doing
all the fog api calls in my models. To start I want to be able to CRUD
launch configurations so ActiveModel looks like a good place to start.
Going down this path though I'm having some design issues where when I
fetch a launch configuration using the "get" method I get
a Fog::AWS::AutoScaling::**Configuration object back. I could pass this
all the way to the controller then up to the view so it has access to all
the attributes on the object but that seems weird to me since my model is
called LaunchConfiguration but the object returned from my model would be
of type Fog::AWS::AutoScaling::**Configuration. If I want to create a
new model based off of everything in the returned object I could do that
but it seems like I would just be repeating everything that comes back from
the fog library but maybe this is the best approach. So my question is
what approach would you take if you were designing something like this.
Thanks in advance,
Jay
Lennart Kindermann
2013-10-25 16:23:53 UTC
Permalink
Hi JayP,

I have exactly the same problem right now and I'm interested in how did you
managed the fog connection/s.
Do you create on every page a Fog::AWS::CloudFormation object? (In my case)

Furthermore I'm quite new to Rails and Ruby in general and I can't figure
out, how and especially where I had to implement the "all"/"find"
functions, where you map/bridge the fog objects to ActiveModel objects.

Thanks,
Lennart
Post by JayP
Just to give this an update, I ended up bridging the fog library to each
model in my application. For example AutoScalingGroup (Model) =>
Fog::AWS::AutoScaleGroup. I create a new AutoScalingGroup instance for
each object I get back from fog. This allows my controllers to fetch my
model objects rather than fog's objects. I used ActiveModel for all of
this and everything seems to work well. I'm still interested though if
others had any other ideas.
Thanks,
Jay
Post by JayP
Hi,
I am thinking of writing a rails app that interacts with the cloud and
wanted to use Fog as my client library to aws. To start I plan on doing
all the fog api calls in my models. To start I want to be able to CRUD
launch configurations so ActiveModel looks like a good place to start.
Going down this path though I'm having some design issues where when I
fetch a launch configuration using the "get" method I get
a Fog::AWS::AutoScaling::Configuration object back. I could pass this all
the way to the controller then up to the view so it has access to all the
attributes on the object but that seems weird to me since my model is
called LaunchConfiguration but the object returned from my model would be
of type Fog::AWS::AutoScaling::Configuration. If I want to create a new
model based off of everything in the returned object I could do that but it
seems like I would just be repeating everything that comes back from the
fog library but maybe this is the best approach. So my question is what
approach would you take if you were designing something like this.
Thanks in advance,
Jay
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Kyle Rames
2013-10-25 16:46:34 UTC
Permalink
One of my co-workers developed a tutorial demonstrating using Fog with
Rails. It might be just what you are looking for.

http://developer.rackspace.com/blog/ruby-on-rails-tutorial-for-the-rackspace-cloud.html

Kyle
Post by Lennart Kindermann
Hi JayP,
I have exactly the same problem right now and I'm interested in how did
you managed the fog connection/s.
Do you create on every page a Fog::AWS::CloudFormation object? (In my case)
Furthermore I'm quite new to Rails and Ruby in general and I can't figure
out, how and especially where I had to implement the "all"/"find"
functions, where you map/bridge the fog objects to ActiveModel objects.
Thanks,
Lennart
Post by JayP
Just to give this an update, I ended up bridging the fog library to each
model in my application. For example AutoScalingGroup (Model) =>
Fog::AWS::AutoScaleGroup. I create a new AutoScalingGroup instance for
each object I get back from fog. This allows my controllers to fetch my
model objects rather than fog's objects. I used ActiveModel for all of
this and everything seems to work well. I'm still interested though if
others had any other ideas.
Thanks,
Jay
Post by JayP
Hi,
I am thinking of writing a rails app that interacts with the cloud and
wanted to use Fog as my client library to aws. To start I plan on doing
all the fog api calls in my models. To start I want to be able to CRUD
launch configurations so ActiveModel looks like a good place to start.
Going down this path though I'm having some design issues where when I
fetch a launch configuration using the "get" method I get
a Fog::AWS::AutoScaling::Configuration object back. I could pass this all
the way to the controller then up to the view so it has access to all the
attributes on the object but that seems weird to me since my model is
called LaunchConfiguration but the object returned from my model would be
of type Fog::AWS::AutoScaling::Configuration. If I want to create a new
model based off of everything in the returned object I could do that but it
seems like I would just be repeating everything that comes back from the
fog library but maybe this is the best approach. So my question is what
approach would you take if you were designing something like this.
Thanks in advance,
Jay
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...