[Rails] Dynamic controller dispatching in rails 3

2010-09-23 Thread fredd
Is there any offical way you could dynamically dispatch controllers in Rails 3? My goal is to invoke different controllers based on path segments like this: /news/sport-blog, should map to a blog controller or /news/sports/2, should map to a page controler In the example cases above, the path sho

[Rails] Advice on memcached caching

2010-04-22 Thread fredd
Hi! I need to cache an overview page that lists the latest events (messages, documents, etc). By the side of each event I show the user who created it (including the user's avatar). I have tried to use a cache this with the cache_key of the page that holds the contents. In the belongs_to method of

[Rails] Re: Abstract rails models

2010-01-13 Thread fredd
Yes, perhaps I do! I found this blog post about some techniques do add behavior to sub classes, http://robots.thoughtbot.com/post/159808315/a-compromise. I am going to try this right away, thanks for your answer! On 13 Jan, 12:32, Colin Law wrote: > 2010/1/13 fredd : > > > Hi,

[Rails] Abstract rails models

2010-01-13 Thread fredd
Hi, I need some advises on rails best practices when it comes to abstract/concrete models/classes in Rails. This is what I want to accomplish: A abstract type of page that holds base functionality like name, memberships, templates and other possible generic stuff. Then I want to have subclasses lik

[Rails] Re: cms like routes

2009-09-26 Thread fredd
I think I solved it my self actually! It turns out that if you name the id parameter something else (like article_id) Rails actually divides the params correctly. So this route: map.article_by_id '*sections/:article_id', :controller => "articles", :action => "show", :article_id => /\d|\d-(.+)/ w

[Rails] Re: cms like routes

2009-09-26 Thread fredd
I think I solved it my self actually! It turns out that if you name the id parameter something else (like article_id) Rails actually divides the params correctly. So this route: map.article_by_id '*sections/:article_id', :controller => "articles", :action => "show", :article_id => /\d|\d-(.+)/ wou

[Rails] cms like routes

2009-09-25 Thread fredd
Hi! I need to be able to construct urls that looks something like this: news/sport/1-article. The news/sport part is a section that an article can be posted in. The idea is that sections can be nested and that it should be reflected in the url. How's that possible to do without globbing the whole

[Rails] Re: STI good or bad for my problem?

2009-05-12 Thread fredd
Yes, I was almost thinking that my self. Thanks for clarifying that. What I now is trying to do is to have a generic model called Item that relates to the different items through a itemable interface (belongs_to :itemable, polymorphic => true). And then the Item model belongs to the Section. What

[Rails] STI good or bad for my problem?

2009-05-12 Thread fredd
Hi. I am currently developing a small course system for student and teachers. The system is divided in sections and sections have many messages, comments, documents and schedules. Pretty easy to set up using ROR, just add some belongs_to and has_many relations. But everything becomes much more com

[Rails] Re: ERB templates in the database

2009-03-24 Thread fredd
Thanks for the replies! I am slow to respond due to vacation and stuff:) It defenently sounds like a good idea to have the model output erb- templates into the file system, I will look into that. But maybe ERB is not safe to use at all if you want the users to alter the templates on the fly (like

[Rails] ERB templates in the database

2009-03-18 Thread fredd
Hi, I am currently developing a small cms in Rails. I decided recently that I need to store both the content and the presentation template in the database for flexibility. The system is based heavily on content blocks and I need different templates for the same content block in different contexts.