Lasertoast
2009-Mar-10 11:46 UTC
Implementing a dashboard-style controller, (think iGoogle)
I''m a relatively new Rails developer, but I think I have a good grasp on the paradigm and I''m trying my best to adhere to RESTful standards. First, let me describe the basic structure of my Rails app (only the pieces relevant to my problem of course): I have a User_Layouts controller. Each User contains multiple User_Layouts. Each User_Layout entry describes a Module that the user is subscribing to (and thus will be displayed on his dashboard - essentially a collection of User_Layouts). Thus, the User_Layouts#index should display a dashboard containing all Modules the User is subscribed to (very similar to iGoogle). I want to be able to create these Modules easily (perhaps using a tailored generate script) - each module having its own model, view, and controller. My question is, what is the proper way to structure this? When User_Layouts#index is invoked, how to I tell Rails to render each Module''s view and place it in the proper div on the User_Layouts#index view? I''ve toyed with rendering partials, and render :update to replace the innerHTML, but none of these seem elegant enough to be standard practice. Any ideas from the Rails experts out there? Any help is greatly appreciated! Jarad D. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Starr Horne
2009-Mar-10 15:30 UTC
Re: Implementing a dashboard-style controller, (think iGoogle)
On Tue, 10 Mar 2009 04:46:22 -0700 (PDT) Lasertoast <jaradd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m a relatively new Rails developer, but I think I have a good grasp > on the paradigm and I''m trying my best to adhere to RESTful standards. > > First, let me describe the basic structure of my Rails app (only the > pieces relevant to my problem of course): > > I have a User_Layouts controller. Each User contains multiple > User_Layouts. Each User_Layout entry describes a Module that the user > is subscribing to (and thus will be displayed on his dashboard - > essentially a collection of User_Layouts). Thus, the > User_Layouts#index should display a dashboard containing all Modules > the User is subscribed to (very similar to iGoogle). I want to be able > to create these Modules easily (perhaps using a tailored generate > script) - each module having its own model, view, and controller. > > My question is, what is the proper way to structure this? When > User_Layouts#index is invoked, how to I tell Rails to render each > Module''s view and place it in the proper div on the User_Layouts#index > view? I''ve toyed with rendering partials, and render :update to > replace the innerHTML, but none of these seem elegant enough to be > standard practice.I would probably just create partials for each type of module. Then you can use render :partial => @module, which will render the correct partial for the object type. SH -- Starr Horne My blog: http://starrhorne.com Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/ --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Lasertoast
2009-Mar-10 17:10 UTC
Re: Implementing a dashboard-style controller, (think iGoogle)
Thanks for the quick response! Unfortunately, I don''t think a partial will work for my purposes. I have a lot of partial use throughout my app to help create DRY views - even across different controllers - but in this case, I need full- fledged MVC components dynamically rendered in a div. A partial will render a particular view, but I also need the controller, it''s actions, and a set of params sent to it. I may have found the answer myself a few minutes ago when I stumbled upon a specialized render method called render_component. This method is actually exactly what I was looking for, but it looks like its slated for deprecation in Rails 2.3. Anyone familiar with this method as far as advantages and disadvantages? I''m assuming there are problems with it since it is being removed (unless it''s going to be placed in a plugin that I''m unaware of). Thanks again in advance for you help! On Mar 10, 11:30 am, Starr Horne <st...-wG8FsLYNbnsysxA8WJXlww@public.gmane.org> wrote:> On Tue, 10 Mar 2009 04:46:22 -0700 (PDT) > > > > Lasertoast <jar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m a relatively new Rails developer, but I think I have a good grasp > > on the paradigm and I''m trying my best to adhere to RESTful standards. > > > First, let me describe the basic structure of my Rails app (only the > > pieces relevant to my problem of course): > > > I have a User_Layouts controller. Each User contains multiple > > User_Layouts. Each User_Layout entry describes a Module that the user > > is subscribing to (and thus will be displayed on hisdashboard- > > essentially a collection of User_Layouts). Thus, the > > User_Layouts#index should display adashboardcontaining all Modules > > the User is subscribed to (very similar to iGoogle). I want to be able > > to create these Modules easily (perhaps using a tailored generate > > script) - each module having its own model, view, and controller. > > > My question is, what is the proper way to structure this? When > > User_Layouts#index is invoked, how to I tell Rails to render each > > Module''s view and place it in the proper div on the User_Layouts#index > > view? I''ve toyed with rendering partials, and render :update to > > replace the innerHTML, but none of these seem elegant enough to be > > standard practice. > > I would probably just create partials for each type of module. Then you can use render :partial => @module, which will render the correct partial for the object type. > > SH > -- > Starr Horne > My blog:http://starrhorne.com > Check out my Helpdesk RailsKit:http://railskits.com/helpdesk/--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Lasertoast
2009-Mar-10 17:11 UTC
Re: Implementing a dashboard-style controller, (think iGoogle)
Thanks for the quick response! Unfortunately, I don''t think a partial will work for my purposes. I have a lot of partial use throughout my app to help create DRY views - even across different controllers - but in this case, I need full- fledged MVC components dynamically rendered in a div. A partial will render a particular view, but I also need the controller, it''s actions, and a set of params sent to it. I may have found the answer myself a few minutes ago when I stumbled upon a specialized render method called render_component. This method is actually exactly what I was looking for, but it looks like its slated for deprecation in Rails 2.3. Anyone familiar with this method as far as advantages and disadvantages? I''m assuming there are problems with it since it is being removed (unless it''s going to be placed in a plugin that I''m unaware of). Thanks again in advance for you help! On Mar 10, 11:30 am, Starr Horne <st...-wG8FsLYNbnsysxA8WJXlww@public.gmane.org> wrote:> On Tue, 10 Mar 2009 04:46:22 -0700 (PDT) > > > > Lasertoast <jar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m a relatively new Rails developer, but I think I have a good grasp > > on the paradigm and I''m trying my best to adhere to RESTful standards. > > > First, let me describe the basic structure of my Rails app (only the > > pieces relevant to my problem of course): > > > I have a User_Layouts controller. Each User contains multiple > > User_Layouts. Each User_Layout entry describes a Module that the user > > is subscribing to (and thus will be displayed on hisdashboard- > > essentially a collection of User_Layouts). Thus, the > > User_Layouts#index should display adashboardcontaining all Modules > > the User is subscribed to (very similar to iGoogle). I want to be able > > to create these Modules easily (perhaps using a tailored generate > > script) - each module having its own model, view, and controller. > > > My question is, what is the proper way to structure this? When > > User_Layouts#index is invoked, how to I tell Rails to render each > > Module''s view and place it in the proper div on the User_Layouts#index > > view? I''ve toyed with rendering partials, and render :update to > > replace the innerHTML, but none of these seem elegant enough to be > > standard practice. > > I would probably just create partials for each type of module. Then you can use render :partial => @module, which will render the correct partial for the object type. > > SH > -- > Starr Horne > My blog:http://starrhorne.com > Check out my Helpdesk RailsKit:http://railskits.com/helpdesk/--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Starr Horne
2009-Mar-10 18:03 UTC
Re: Implementing a dashboard-style controller, (think iGoogle)
> Unfortunately, I don''t think a partial will work for my purposes. I > have a lot of partial use throughout my app to help create DRY views - > even across different controllers - but in this case, I need full- > fledged MVC components dynamically rendered in a div. A partial will > render a particular view, but I also need the controller, it''s > actions, and a set of params sent to it.Yeah, I would avoid using components, as they''re deprecated. And you may already know this, but just because a partial is rendered as a result of a request to a specific controller, that doesn''t mean that the partial can''t link to other controllers or render arbitrary content. SH -- Starr Horne My blog: http://starrhorne.com Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/ --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---