Ruby on Rails
Wednesday, November 25, 2015
On Wednesday, November 25, 2015 at 6:09:44 AM UTC-5, Colin Law wrote:
On 25 November 2015 at 09:40, fugee ohu <fuge...@gmail.com> wrote:
> On Wednesday, November 25, 2015 at 4:16:57 AM UTC-5, Colin Law wrote:
>>
>> On 25 November 2015 at 08:52, fugee ohu <fuge...@gmail.com> wrote:
>> > I wanna display categories in the side pane and listings in the main,
>> > both
>> > divisions of the same layout How would I do that?
>>
>> Using CSS probably.
>>
>> Colin
>
>
> Of course, the listings and categories are related ha ha I wanna show the
> listings for the category in the main and the sub-categories of that
> category in the side Problem is that there's 2 controllers involved, I
> dunno how to invoke them both to render to the same layout either directly
> or through partials
You are confused about the MVC model. You can access any model you
like in a controller and setup the data for both panes of the view.
What are the relationships between the various models (categories,
listings, sub-categories or whatever)? Getting those right is
crucial. If Category is a self referential model then it is important
to specify that correctly to save yourself a lot of work. Google for
rails self referential models if you don't know how to do it. If you
find yourself accessing category.parent_id in the code then you are
almost certainly not got it right.
Thanks Colin, I realized that what I needed to do was create a new controller to pull data from both models for combined presentation in views
-- 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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/481ca4d2-dee7-4371-b7a0-c639dc935f8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment