[Brug-talk] Controllers owning controllers

Maarten Porters maarten at fastfocus.be
Mon Nov 12 17:56:39 EST 2007


Hi Thomas,

after taking a quick look at your drawing, I'd consider just making a 
controllers & models
for each entity. I know it's sometimes a bit hard to get a good 
structure for your app. Just
try not to make it more complicated then it actually is. (I guess this 
is a pretty useless tip :)).
When I'm stuck with this kind of problems, I start scaffolding my app in 
different ways. If it doesn't work,
I start over again without losing too much time. After a while you'll 
get a better understanding
of your app and rails.

map.connect ':dummy', :controller => 'redirector', :action => 'redirect' => I really don't like this. Feels like a hack. (just my first impression)


greetz,

Maarten



Thomas Richard schreef:
> Hey,
>
> First of all, thanks for the reply Tom. Thought I wouldn't get any.
>
> I've quickly drawn something in paint and put it online. You can find
> the image here:
> http://www.statsfreakz.net/images/ror.jpg
>
> As you can see the 'smaller modules' like workhours and products are
> shared between the bigger categories. They have exactly the same
> functionality but I'd like to have the sidemenu render the options
> that belong to their main category. So when you're working in the
> projects page you get a sidebar with different options then when
> you're working in the delivery page. I've currently set this up with
> some routing and I'm thinking of writing a controller for every
> smaller module so i can just put them on any page i want without
> changing code.
>
> I've added these routes to routes.rb
>   map.connect ':dummy/:controller/:action/:id'
>   map.connect ':dummy', :controller => 'redirector', :action => 'redirect'
>
> Then the template application.rhtml reads out the dummy variable and
> renders the correct sidebar (this code is put in a helper). I really
> don't know if this is 'the rails way' but i couldn't come up with
> another solution myself. This seems to work fine and didn't cost me
> alot of time to set up. So i might stick to this unless someone has a
> better idea.
>
> Greetings
> Thomas
>
> 2007/11/12, Tom Klaasen <tom at 10to1.be>:
>   
>> Hi Thomas,
>>
>> On 11/10/07, Thomas Richard <thomas9999 at gmail.com> wrote:
>>     
>>> Hey Belgian Rubyists,
>>>
>>> I've just completed the book 'Agile web development in Rails' and I've
>>> been playing around a bit before i start to work in my first real
>>> rails application. Now while playing I came to a problem wich i might
>>> be able to solve but if I'd do it my way it would break all the Rails
>>> conventions the book was been telling about. So there should be a more
>>> 'agile' solution to this problem.
>>>
>>> Let me try explain the problem:
>>> The application would be build on a few big modules e.g: projects,
>>> services, delivery's, stock, ...
>>> Under these big modules I'd have a few smaller modules e.g: employees,
>>> products, price requests, ...
>>>       
>> What do you understand under "module"? From your explanation, it seems that
>> you consider one module as one web page.
>>
>>
>>     
>>> The big problem now is that i would need to share the functionalirty
>>> of these smaller modules between the bigger modules. The functions of
>>> all the smaller modules should be exactly the same everywhere. It
>>> probably has a simple solution but i can't seem to find one. The way
>>> I'd try to solve the problem is making a controller for the projects,
>>> services, .. modules , but i don't know how I'd have to handle the
>>> smaller ones. I could put them in different rb files and require them
>>> into the controllers but that just doesn't seem right.
>>>       
>> I'm still a bit lost here... How do the smaller modules belong to the bigger
>> ones? Why are they put "everywhere"?
>>
>>
>>     
>>> When i was thinking about the URI's i came to a possible second
>>> solution. The URI's would have to look something like
>>> app/projects/pricerequests/new
>>> Now that gave me a new perspective on the case. I could actually put
>>> the smaller modules into controllers and just use the greater modules
>>> as dummies. They're just there to organize the smaller modules into
>>> groups. Then again, i wouldn't know how i could get something like
>>> this working in rails as this would screw up the way the view system
>>> works?
>>>
>>> As you can probably see i found it hard to explain the problem but i
>>> hope any of you can make something out of this. Would be nice of
>>> someone wants to discuss about this with me (in private or not).
>>>       
>> A whiteboard (or a scrap or paper) would indeed be nice, I think. But please
>> try to explain your problem a bit more here, I'd like to help. What does
>> your application look like? How do you see the user flow? What are the
>> relations between the modules?
>>
>>     
>>> I
>>> hope questions like these are allowed in this mailing list ;)
>>>       
>> That's why this list is here in the first place, isn't it?
>>
>>
>> --
>> Tom Klaasen
>> 10to1
>>
>>
>> _______________________________________________
>> Brug-talk mailing list
>> Brug-talk at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/brug-talk
>>
>>
>>     
> _______________________________________________
> Brug-talk mailing list
> Brug-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/brug-talk
>
>   



More information about the Brug-talk mailing list