Hi, I unable to follow DRY principle. I struck in situation where actions are same but controller are different.Wait,let me explain you with example . http://www.example.com/en/xyz/abc http://www.example.com/en/mnb/abc http://www.example.com/en/xkj/abc http://www.example.com/en/cbc/abc As you see in above URLs second last parameter is changing every time . How to tackle such situation. Currently i thought to use scope method in config/route.rb or i will create separate controller for each /xyz/ , /mnb/ , /xkj/ . How do you solve such problem ? It will be good if you tell me way which follow DRY and flexible too. Thanks. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Friday, November 16, 2012 8:18:04 AM UTC, Ruby-Forum.com User wrote:> > Hi, > I unable to follow DRY principle. I struck in situation where actions > are same but controller are different.Wait,let me explain you with > example . > > http://www.example.com/en/xyz/abc > http://www.example.com/en/mnb/abc > http://www.example.com/en/xkj/abc > http://www.example.com/en/cbc/abc > > As you see in above URLs second last parameter is changing every time . > How to tackle such situation. > >It''s hard to say when I don''t knwo what you''re doing in those controllers but if they''re the same and it''s just the routing you''re asking about you could have a route such as match ''/en/:param1/abc'', :to => ''foo#index'' which would route all those urls to the index action of your foo controller, setting params[:param1] appropriately Fred Currently i thought to use scope method in config/route.rb or i will> create separate controller for each /xyz/ , /mnb/ , /xkj/ . > > How do you solve such problem ? It will be good if you tell me way which > follow DRY and flexible too. > > Thanks. > > -- > 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/S1SLm2MdLz8J. For more options, visit https://groups.google.com/groups/opt_out.
> It''s hard to say when I don''t knwo what you''re doing in those > controllersContents are different for all whose urls,but having same layout . -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
if generated content is different match ''/en/:param1/abc'', :to => ''foo#param1'' and you will have different actions #xyz , #mnb , #xkj, #cbc in your foo controller with same layout can you clarify using samples urls ? Le vendredi 16 novembre 2012 09:48:45 UTC+1, Ruby-Forum.com User a écrit :> > > It''s hard to say when I don''t knwo what you''re doing in those > > controllers > > > Contents are different for all whose urls,but having same layout . > > -- > 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/rRieDN6VsRoJ. For more options, visit https://groups.google.com/groups/opt_out.
Kad Kerforn wrote in post #1084737:> if generated content is different > > match ''/en/:param1/abc'', :to => ''foo#param1'' > > and you will have different actions #xyz , #mnb , #xkj, #cbc in > your > foo controller > with same layout > > can you clarify using samples urls ? > > > > Le vendredi 16 novembre 2012 09:48:45 UTC+1, Ruby-Forum.com User a crit > :sample urls . http://0.0.0.0:3000/fr/School_1/index http://0.0.0.0:3000/fr/School_1/about_us http://0.0.0.0:3000/fr/School_1/admission http://0.0.0.0:3000/fr/School_2/index http://0.0.0.0:3000/fr/School_2/about_us http://0.0.0.0:3000/fr/School_2/admission http://0.0.0.0:3000/fr/School_3/index http://0.0.0.0:3000/fr/School_3/about_us http://0.0.0.0:3000/fr/School_3/admission http://0.0.0.0:3000/fr/School_4/index http://0.0.0.0:3000/fr/School_4/about_us http://0.0.0.0:3000/fr/School_4/admission It shares same layout means class School_1Controller < ApplicationController layout "shared_layout.html.erb" end class School_2Controller < ApplicationController layout "shared_layout.html.erb" end . . . -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 16 November 2012 15:09, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Kad Kerforn wrote in post #1084737: >> if generated content is different >> >> match ''/en/:param1/abc'', :to => ''foo#param1'' >> >> and you will have different actions #xyz , #mnb , #xkj, #cbc in >> your >> foo controller >> with same layout >> >> can you clarify using samples urls ? >> >> >> >> Le vendredi 16 novembre 2012 09:48:45 UTC+1, Ruby-Forum.com User a crit >> : > sample urls . > http://0.0.0.0:3000/fr/School_1/index > http://0.0.0.0:3000/fr/School_1/about_us > http://0.0.0.0:3000/fr/School_1/admission > > http://0.0.0.0:3000/fr/School_2/index > http://0.0.0.0:3000/fr/School_2/about_us > http://0.0.0.0:3000/fr/School_2/admissionAre school_1 and school_2 different models? If so, why? I see they different controllers? Why? Colin> > http://0.0.0.0:3000/fr/School_3/index > http://0.0.0.0:3000/fr/School_3/about_us > http://0.0.0.0:3000/fr/School_3/admission > > http://0.0.0.0:3000/fr/School_4/index > http://0.0.0.0:3000/fr/School_4/about_us > http://0.0.0.0:3000/fr/School_4/admission > > It shares same layout means > > class School_1Controller < ApplicationController > layout "shared_layout.html.erb" > end > > class School_2Controller < ApplicationController > layout "shared_layout.html.erb" > end > . > . > . > > -- > 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1084745:> On 16 November 2012 15:09, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> can you clarify using samples urls ? >> http://0.0.0.0:3000/fr/School_2/index >> http://0.0.0.0:3000/fr/School_2/about_us >> http://0.0.0.0:3000/fr/School_2/admission > > Are school_1 and school_2 different models? If so, why? > I see they different controllers? Why? > > Colini didn''t used model yet . As you see,above the site is partially static , so i just been focused on views/ . This is what my problem is and it is what i want to know. How did you tackle such situation ?> I see they different controllers? Why?if you have some idea , tell me . -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 16 November 2012 15:25, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1084745: >> On 16 November 2012 15:09, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> can you clarify using samples urls ? >>> http://0.0.0.0:3000/fr/School_2/index >>> http://0.0.0.0:3000/fr/School_2/about_us >>> http://0.0.0.0:3000/fr/School_2/admission >> >> Are school_1 and school_2 different models? If so, why? >> I see they different controllers? Why? >> >> Colin > > i didn''t used model yet . As you see,above the site is partially static > , so i just been focused on views/ . > This is what my problem is and it is what i want to know. How did you > tackle > such situation ? > >> I see they different controllers? Why? > > if you have some idea , tell me .What is wrong with the suggestion offered by Fred, which allows you send them to the same controller but with params indicating which school it is? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
if all pages are static , isn''t better to use a gem like HighVoltage ? it''s what I have been using when no need for CMS... Le vendredi 16 novembre 2012 16:39:51 UTC+1, Colin Law a écrit :> > On 16 November 2012 15:25, Paritosh P. <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org <javascript:>> > wrote: > > Colin Law wrote in post #1084745: > >> On 16 November 2012 15:09, Paritosh P. <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org<javascript:>> > wrote: > >>>> can you clarify using samples urls ? > >>> http://0.0.0.0:3000/fr/School_2/index > >>> http://0.0.0.0:3000/fr/School_2/about_us > >>> http://0.0.0.0:3000/fr/School_2/admission > >> > >> Are school_1 and school_2 different models? If so, why? > >> I see they different controllers? Why? > >> > >> Colin > > > > i didn''t used model yet . As you see,above the site is partially static > > , so i just been focused on views/ . > > This is what my problem is and it is what i want to know. How did you > > tackle > > such situation ? > > > >> I see they different controllers? Why? > > > > if you have some idea , tell me . > > What is wrong with the suggestion offered by Fred, which allows you > send them to the same controller but with params indicating which > school it is? > > Colin >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ZYIX-sls_KYJ. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1084753:> On 16 November 2012 15:25, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> Colin >> >> i didn''t used model yet . As you see,above the site is partially static >> , so i just been focused on views/ . >> This is what my problem is and it is what i want to know. How did you >> tackle >> such situation ? >> >>> I see they different controllers? Why? >> >> if you have some idea , tell me . > > What is wrong with the suggestion offered by Fred, which allows you > send them to the same controller but with params indicating which > school it is? > > Colini didn''t said anything for his suggestion . but doesn''t fit my needs.> > >if all pages are static , isn''t better to use a gem like HighVoltage ? >it''s what I have been using when no need for CMS... > > >Le vendredi 16 novembre 2012 16:39:51 UTC+1, Colin Law a crit :logic behind HighVoltage is not big.I rather construct with scratch as per my needs.Moreover my pages are not fully static also.Anyway thanks for your suggestion . -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 16 November 2012 16:29, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1084753: >> On 16 November 2012 15:25, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> Colin >>> >>> i didn''t used model yet . As you see,above the site is partially static >>> , so i just been focused on views/ . >>> This is what my problem is and it is what i want to know. How did you >>> tackle >>> such situation ? >>> >>>> I see they different controllers? Why? >>> >>> if you have some idea , tell me . >> >> What is wrong with the suggestion offered by Fred, which allows you >> send them to the same controller but with params indicating which >> school it is? >> >> Colin > > i didn''t said anything for his suggestion . but doesn''t fit my needs.In that case I do not understand your needs. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1084776:> On 16 November 2012 16:29, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>>> I see they different controllers? Why? >>>> >>>> if you have some idea , tell me . >>> >>> What is wrong with the suggestion offered by Fred, which allows you >>> send them to the same controller but with params indicating which >>> school it is? >>> >>> Colin >> >> i didn''t said anything for his suggestion . but doesn''t fit my needs. > > In that case I do not understand your needs. > > Colinif so,Sorry if i wasted your time. STOP -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 16 November 2012 16:41, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1084776: >> On 16 November 2012 16:29, Paritosh P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>>>> I see they different controllers? Why? >>>>> >>>>> if you have some idea , tell me . >>>> >>>> What is wrong with the suggestion offered by Fred, which allows you >>>> send them to the same controller but with params indicating which >>>> school it is? >>>> >>>> Colin >>> >>> i didn''t said anything for his suggestion . but doesn''t fit my needs. >> >> In that case I do not understand your needs. >> >> Colin > > if so,Sorry if i wasted your time. > > STOPStop what? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
The suggestion posted by fred is really well suited for your need. for instance, if you go to 0.0.0.0:3000/fr/School1/abc this will be routed to the #abc controller, but with param1=''School1'' def abc @School=School.find_by_name(:param1) @content=@school.pages.find_by_name(action_name) end Now in your layout, you will have available @School, which has all the information about the school, and @content, which contains the content of the page ''about us'' etc etc. If your content is static, this is not a good solution. Au revoir, Ace On Friday, November 16, 2012 4:18:04 AM UTC-4, Ruby-Forum.com User wrote:> > Hi, > I unable to follow DRY principle. I struck in situation where actions > are same but controller are different.Wait,let me explain you with > example . > > http://www.example.com/en/xyz/abc > http://www.example.com/en/mnb/abc > http://www.example.com/en/xkj/abc > http://www.example.com/en/cbc/abc > > As you see in above URLs second last parameter is changing every time . > How to tackle such situation. > > Currently i thought to use scope method in config/route.rb or i will > create separate controller for each /xyz/ , /mnb/ , /xkj/ . > > How do you solve such problem ? It will be good if you tell me way which > follow DRY and flexible too. > > Thanks. > > -- > 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/MZgAeWc_2m0J. For more options, visit https://groups.google.com/groups/opt_out.