I''m trying to follow DRY way of coding. I decided to make my code cleanes. Basically, app has 2 types of what to show to user, depending on content. So I want to set up inside show method conditional, and then two different inner methods for conditional. And, of cource, two different views for this methods. For exapmle: def show If conditional show_empty else show_with_content end def show_empty #some code end def show_with_content #some code end end And I want controller to request show_emty.html.erb and show_with_content.html.erb, based on what inner method was called. Because my view code became really dirty and overcomplicated. But trying to do that, I faced several errors. (nil class, wrong route). What should I set up in routes? And how explain to Rails that it should not to seek show.html.erb, but view for inner methods? -- 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/msg/rubyonrails-talk/-/e3UXNbjxunoJ. For more options, visit https://groups.google.com/groups/opt_out.
On Tue, Mar 19, 2013 at 7:36 AM, Barry <burmanz-JGs/UdohzUI@public.gmane.org> wrote:> I''m trying to follow DRY way of coding. I decided to make my code cleanes. > Basically, app has 2 types of what to show to user, depending on content. So > I want to set up inside show method conditional, and then two different > inner methods for conditional. And, of cource, two different views for this > methods. > For exapmle: > def show > If conditional > show_empty > else > show_with_content > end > def show_empty > #some code > end > def show_with_content > #some code > end > end > > And I want controller to request show_emty.html.erb and > show_with_content.html.erb, based on what inner method was called. > Because my view code became really dirty and overcomplicated. > But trying to do that, I faced several errors. (nil class, wrong route). > What should I set up in routes? And how explain to Rails that it should not > to seek show.html.erb, but view for inner methods?The concept is sound. However, with no details about what your code is actually doing, real error messages, and the like, it''s very hard to offer any sort of help. Please read through the rails debugging guide[1] to see if that will help you. [1]: http://guides.rubyonrails.org/debugging_rails_applications.html -- 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 For more options, visit https://groups.google.com/groups/opt_out.
On 21 March 2013 01:46, tamouse mailing lists <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Mar 19, 2013 at 7:36 AM, Barry <burmanz-JGs/UdohzUI@public.gmane.org> wrote: >> I''m trying to follow DRY way of coding. I decided to make my code cleanes. >> Basically, app has 2 types of what to show to user, depending on content. So >> I want to set up inside show method conditional, and then two different >> inner methods for conditional. And, of cource, two different views for this >> methods. >> For exapmle: >> def show >> If conditional >> show_empty >> else >> show_with_content >> end >> def show_empty >> #some code >> end >> def show_with_content >> #some code >> end >> end >> >> And I want controller to request show_emty.html.erb and >> show_with_content.html.erb, based on what inner method was called. >> Because my view code became really dirty and overcomplicated. >> But trying to do that, I faced several errors. (nil class, wrong route). >> What should I set up in routes? And how explain to Rails that it should not >> to seek show.html.erb, but view for inner methods? > > The concept is sound. However, with no details about what your code is > actually doing, real error messages, and the like, it''s very hard to > offer any sort of help. Please read through the rails debugging > guide[1] to see if that will help you. > > > [1]: http://guides.rubyonrails.org/debugging_rails_applications.htmlA further suggestion, since it seems the OP is lacking some knowledge of Rails basics such as routing, is to work right through a good tutorial such as railstutorial.org, which is free to use online, in order to better understand the basics. Also for routing look a the rails guide on routing (and all the other guides in fact). Colin -- 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 For more options, visit https://groups.google.com/groups/opt_out.