Hi, I have seen that when using rails for big applications especially the ones with a lot of dynamic content. for example: profile pages in social network apps, newspaper websites etc. The Views in such rails apps seem to have a lot of clutter, lots of render statements, ''if'' statements etc.etc. Is there a way to avoid it or cleaner way to do it. Thanks, Rishav --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Rishav, The cleanest way is to try and move as much logic into the models and controllers( depending on the context) and then moving a lot of the repetitive view logic into partials. There is an excellent video on this on RailsCasts http://railscasts.com/episodes/55-cleaning-up-the-view Hope this helps. Rob On Dec 13, 4:45 pm, "Rishav Rastogi" <rishav.rast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I have seen that when using rails for big applications especially the ones > with a lot of dynamic content. for example: profile pages in social network > apps, newspaper websites etc. > > The Views in such rails apps seem to have a lot of clutter, lots of render > statements, ''if'' statements etc.etc. Is there a way to avoid it or cleaner > way to do it. > > Thanks, > Rishav--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Don''t forget about helpers. Helpers that take blocks are especially useful, it''s a really easy way to conditionally display some content without cluttering the view. # Helper def is_authorized(action, resource, &block) yield if current_user.permission_check(action, resource) end # View <% is_authorized(:edit, @user) do %> <%= link_to "Edit", edit_user_path(@user) %> <% end %> On Dec 13, 3:52 am, Robert Zolkos <zol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Rishav, > > The cleanest way is to try and move as much logic into the models and > controllers( depending on the context) and then moving a lot of the > repetitive view logic into partials. > > There is an excellent video on this on RailsCastshttp://railscasts.com/episodes/55-cleaning-up-the-view > > Hope this helps. > > Rob > > On Dec 13, 4:45 pm, "Rishav Rastogi" <rishav.rast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I have seen that when using rails for big applications especially the ones > > with a lot of dynamic content. for example: profile pages in social network > > apps, newspaper websites etc. > > > The Views in such rails apps seem to have a lot of clutter, lots of render > > statements, ''if'' statements etc.etc. Is there a way to avoid it or cleaner > > way to do it. > > > Thanks, > > Rishav--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What are the performance impacts of these various techniques? Has anyone managed or reduced complexity using layouts in any particularly clever ways? al On Sun, Dec 14, 2008 at 12:14 AM, Andrew Bloom <akbloom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Don''t forget about helpers. Helpers that take blocks are especially > useful, it''s a really easy way to conditionally display some content > without cluttering the view. > > # Helper > def is_authorized(action, resource, &block) > yield if current_user.permission_check(action, resource) > end > > # View > <% is_authorized(:edit, @user) do %> > <%= link_to "Edit", edit_user_path(@user) %> > <% end %> > > On Dec 13, 3:52 am, Robert Zolkos <zol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi Rishav, > > > > The cleanest way is to try and move as much logic into the models and > > controllers( depending on the context) and then moving a lot of the > > repetitive view logic into partials. > > > > There is an excellent video on this on RailsCastshttp:// > railscasts.com/episodes/55-cleaning-up-the-view > > > > Hope this helps. > > > > Rob > > > > On Dec 13, 4:45 pm, "Rishav Rastogi" <rishav.rast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > > > I have seen that when using rails for big applications especially the > ones > > > with a lot of dynamic content. for example: profile pages in social > network > > > apps, newspaper websites etc. > > > > > The Views in such rails apps seem to have a lot of clutter, lots of > render > > > statements, ''if'' statements etc.etc. Is there a way to avoid it or > cleaner > > > way to do it. > > > > > Thanks, > > > Rishav > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi guys, Thanks for the replies. I have tried a bunch of the things mentioned above but still even with the partials and moving code to the helpers,I dont like the result. May be I haven''t done things right. But humor me for a thought I had when thinking about the solution.. I have simple profile page filled up with content from different models and the page is full of "render" statements. Is there a more CMS type solution here. Like for example in Drupal,(aside from the fact its a little inflexible) , manages views in a very clean and decoupled manner from the actual application. It delegates the page content to php variables Like "side-bar" "content" "footer" which acts like a base theme and then you can have separate sub themes managing individual components. The sub themes are combined and put in place in the base theme to render the final output without (atleast most of the time) the user telling Drupal. Can anyone recommend any good Rails / Ruby based CMS? Thanks Rishav On Dec 14, 1:14 pm, Andrew Bloom <akbl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Don''t forget about helpers. Helpers that take blocks are especially > useful, it''s a really easy way to conditionally display some content > without cluttering the view. > > # Helper > def is_authorized(action, resource, &block) > yield if current_user.permission_check(action, resource) > end > > # View > <% is_authorized(:edit, @user) do %> > <%= link_to "Edit", edit_user_path(@user) %> > <% end %> > > On Dec 13, 3:52 am, Robert Zolkos <zol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Rishav, > > > The cleanest way is to try and move as much logic into the models and > > controllers( depending on the context) and then moving a lot of the > > repetitive view logic into partials. > > > There is an excellent video on this on RailsCastshttp://railscasts.com/episodes/55-cleaning-up-the-view > > > Hope this helps. > > > Rob > > > On Dec 13, 4:45 pm, "Rishav Rastogi" <rishav.rast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > > > I have seen that when using rails for big applications especially the ones > > > with a lot of dynamic content. for example: profile pages in social network > > > apps, newspaper websites etc. > > > > TheViewsin such rails apps seem to have a lot ofclutter, lots of render > > > statements, ''if'' statements etc.etc. Is there a way toavoidit or cleaner > > > way to do it. > > > > Thanks, > > > Rishav--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rishav, You should check out Radiant CMS. It''s Rails-based and has the same type of content parts to the pages that you''re describing from Drupal. ~Thadd On Dec 16, 9:08 am, rishav <rishav.rast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi guys, > > Thanks for the replies. I have tried a bunch of the things mentioned > above but still even with the partials and moving code to the > helpers,I dont like the result. > May be I haven''t done things right. But humor me for a thought I had > when thinking about the solution.. > I have simple profile page filled up with content from different > models and the page is full of "render" statements. Is there a more > CMS type solution here. > > Like for example in Drupal,(aside from the fact its a little > inflexible) , manages views in a very clean and decoupled manner > from the actual application. It delegates the page content to php > variables Like "side-bar" "content" "footer" which acts like a base > theme and then you can have separate sub themes managing individual > components. The sub themes are combined and put in place in the base > theme to render the final output without (atleast most of the time) > the user telling Drupal. > > Can anyone recommend any good Rails / Ruby based CMS? > > Thanks > Rishav > > On Dec 14, 1:14 pm, Andrew Bloom <akbl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Don''t forget about helpers. Helpers that take blocks are especially > > useful, it''s a really easy way to conditionally display some content > > without cluttering the view. > > > # Helper > > def is_authorized(action, resource, &block) > > yield if current_user.permission_check(action, resource) > > end > > > # View > > <% is_authorized(:edit, @user) do %> > > <%= link_to "Edit", edit_user_path(@user) %> > > <% end %> > > > On Dec 13, 3:52 am, Robert Zolkos <zol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi Rishav, > > > > The cleanest way is to try and move as much logic into the models and > > > controllers( depending on the context) and then moving a lot of the > > > repetitive view logic into partials. > > > > There is an excellent video on this on RailsCastshttp://railscasts.com/episodes/55-cleaning-up-the-view > > > > Hope this helps. > > > > Rob > > > > On Dec 13, 4:45 pm, "Rishav Rastogi" <rishav.rast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > > > I have seen that when using rails for big applications especially the ones > > > > with a lot of dynamic content. for example: profile pages in social network > > > > apps, newspaper websites etc. > > > > > TheViewsin such rails apps seem to have a lot ofclutter, lots of render > > > > statements, ''if'' statements etc.etc. Is there a way toavoidit or cleaner > > > > way to do it. > > > > > Thanks, > > > > Rishav--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''ll check it out Thanks Rishav On Dec 18, 5:23 pm, Thadd <thadd.sel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Rishav, > > You should check out Radiant CMS. It''s Rails-based and has the same > type of content parts to the pages that you''re describing from Drupal. > > ~Thadd > > On Dec 16, 9:08 am, rishav <rishav.rast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi guys, > > > Thanks for the replies. I have tried a bunch of the things mentioned > > above but still even with the partials and moving code to the > > helpers,I dont like the result. > > May be I haven''t done things right. But humor me for a thought I had > > when thinking about the solution.. > > I have simple profile page filled up with content from different > > models and the page is full of "render" statements. Is there a more > > CMS type solution here. > > > Like for example in Drupal,(aside from the fact its a little > > inflexible) , manages views in a very clean and decoupled manner > > from the actual application. It delegates the page content to php > > variables Like "side-bar" "content" "footer" which acts like a base > > theme and then you can have separate sub themes managing individual > > components. The sub themes are combined and put in place in the base > > theme to render the final output without (atleast most of the time) > > the user telling Drupal. > > > Can anyone recommend any good Rails / Ruby based CMS? > > > Thanks > > Rishav > > > On Dec 14, 1:14 pm, Andrew Bloom <akbl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Don''t forget about helpers. Helpers that take blocks are especially > > > useful, it''s a really easy way to conditionally display some content > > > without cluttering the view. > > > > # Helper > > > def is_authorized(action, resource, &block) > > > yield if current_user.permission_check(action, resource) > > > end > > > > # View > > > <% is_authorized(:edit, @user) do %> > > > <%= link_to "Edit", edit_user_path(@user) %> > > > <% end %> > > > > On Dec 13, 3:52 am, Robert Zolkos <zol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Rishav, > > > > > The cleanest way is to try and move as much logic into the models and > > > > controllers( depending on the context) and then moving a lot of the > > > > repetitive view logic into partials. > > > > > There is an excellent video on this on RailsCastshttp://railscasts.com/episodes/55-cleaning-up-the-view > > > > > Hope this helps. > > > > > Rob > > > > > On Dec 13, 4:45 pm, "Rishav Rastogi" <rishav.rast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi, > > > > > > I have seen that when using rails for big applications especially the ones > > > > > with a lot of dynamic content. for example: profile pages in social network > > > > > apps, newspaper websites etc. > > > > > > TheViewsin such rails apps seem to have a lot ofclutter, lots of render > > > > > statements, ''if'' statements etc.etc. Is there a way toavoidit or cleaner > > > > > way to do it. > > > > > > Thanks, > > > > > Rishav--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---