Hello Everyone, What if you don''t want your model to be tied to a database therefore not ActiveRecord, where do you put that model instead? I want to write a class that would wrap together the various functions from, let''s say, the AWS API. Would I write that class and place it in the models directory? Or should I place it elsewhere? Thank you. Peter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/dd7cee3c-e888-40c1-9597-b43eadb27e57%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jordon Bedwell
2013-Oct-12 22:49 UTC
Re: What if you don''t want your model to be from Active Record?
On Sat, Oct 12, 2013 at 5:06 PM, Peter <peter-I8Khkwz7QpbQT0dZR+AlfA@public.gmane.org> wrote:> What if you don''t want your model to be tied to a database therefore not > ActiveRecord, where do you put that model instead?In models, because nobody said models had to be ActiveRecord because models define behaviors but if you want the Railism that "models should be ActiveRecord" kicked out of your models you should upgrade to Rails 4 where now you can have ActiveRecord::Base and ActiveModel::Model.> I want to write a class that would wrap together the various functions from, > let''s say, the AWS API. Would I write that class and place it in the models > directory? Or should I place it elsewhere? Thank you.It depends on what you mean but "wrap together various functions". -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnwfmV9k2SpbkivirKSYf0ScCZF%2Bv8A4FwLQC732Y8aDdw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Peter
2013-Oct-12 23:11 UTC
Re: What if you don''t want your model to be from Active Record?
By "wrap together", I meant I would write a single function for all the functions I would use from the AWS API. So, I should put this in the models directory, right? I want the controller to remain a "controller" with respect to rails-isms. class MyAWSAPI def list_servers ... call to AWS API to get list of servers... end def show_server(int) ... call to AWS API to get info on server int ... end end On Saturday, October 12, 2013 3:49:59 PM UTC-7, Jordon Bedwell wrote:> > On Sat, Oct 12, 2013 at 5:06 PM, Peter <pe...-I8Khkwz7QpbQT0dZR+AlfA@public.gmane.org <javascript:>> > wrote: > > What if you don''t want your model to be tied to a database therefore not > > ActiveRecord, where do you put that model instead? > > In models, because nobody said models had to be ActiveRecord because > models define behaviors but if you want the Railism that "models > should be ActiveRecord" kicked out of your models you should upgrade > to Rails 4 where now you can have ActiveRecord::Base and > ActiveModel::Model. > > > I want to write a class that would wrap together the various functions > from, > > let''s say, the AWS API. Would I write that class and place it in the > models > > directory? Or should I place it elsewhere? Thank you. > > It depends on what you mean but "wrap together various functions". >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/57682901-1e89-4e35-bd21-1a399bfea0e2%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Robert Walker
2013-Oct-13 00:09 UTC
Re: What if you don''t want your model to be from Active Record?
Peter wrote in post #1124413:> By "wrap together", I meant I would write a single function for all the > functions I would use from the AWS API. > > So, I should put this in the models directory, right? I want the > controller > to remain a "controller" with respect to rails-isms. > > class MyAWSAPI > def list_servers > ... call to AWS API to get list of servers... > end > > def show_server(int) > ... call to AWS API to get info on server int ... > end > endYes, that would be a model object and models would be a good place to put that. You might even consider implementing ActiveModel with your class and gain some ActiveRecord like behavior, but not actually be an ActiveRecord subclass. Depends on your needs. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a17825a565ddaa4782ae9aa7c8d8db27%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.