Hey guys. I'm creating a rails app and being one of the first times I've used the MVC pattern, let alone rails, I'm running into ambiguity and uncertainty. I already defined an application.html.erb
which is working great, it has a yield
statement which renders the current action's view.
I want application.html.erb to contain some dynamic content though, for example in a sidebar. I am wondering where the code for this dynamic content should go. While experimenting, I created a controller called home and defined the logic there, though I don't think it should go there. It's just that I didn't create a model because I don't need any form of database for this, and most of the examples I've seen use models specifically to interact with some form of persistent data. In the home controller I defined the index action, and when I go to mysite.com/home/ it shows the dynamic content I wanted to see, but in the content section of the layout (where the yield statement is).
Basically I feel all tangled up now, and I am wondering how I would go about placing this dynamic content in the side bar of my application.html.erb layout so that it remains throughout my site, since my entire site uses this layout. I was thinking about using application_controller.rb
, but something tells me I should leave that alone.
Thanks, let me know if anything doesn't make sense. Pretty difficult to be clear when I am really confused.