EDIT:
Okay, so using cells I have got it running, indeed the rb file created by the cells scripted needed:
helper ApplicationHelper
this got past the error in the comments below, but now inside my application helper, i have a method:
def hr_user_past
@current_year = current_year
@hr_user_past ||= Employee.where("username=? and year < ?", session[:hr_user].username, @current_year).order("Year DESC") if session[:hr_user]
@past_times = @current_year - 2011
@blart = 'test'
end
And alas, this now cannot find current_year which is a def method in my application_controller.rb, so I think my flow is all messed up and not sure what I need to have where for a good solid “include”.
Def of the current_year from application controller
class ApplicationController < Actioncontroller::Base
helper_method :current_year
...
...
def current_year
OpenPeriod.maximum :year
end
end
I also am worried all this work still wont solve the issue I am having with the twitter bootstrap modal dialog being called from a layout and not fadeing in all the way with data (minute i put the same code in a view, it works right)… but one issue at a time i guess…
END EDIT
Trying to have an objective question here though. Some background:
I have a navigation layout that has this nice login, home button and a few others on it. It works fine, lately the customer wanted some more functionality added to this namely a smart button that drops down dynamically with data filled out (stuff from years past from old forms we use).
So the app used a twitter bootstrap modal elsewhere. I just posted this question here:
twitter bootstrap modal does not work in rails3 layout?
Where I am having an issue with this modal working correctly from the layout. Then I got to thinking, this modal that drops down has some good amount of data usually from a specific controller, but they want to see this data at any moment. Is the layout way of doing this not the way, should I build an application helper .rb code to fill out a partial and include that partial on every page in the app? ( seeems like it should fix my modal displaying oddly, like constantly faded issue). I think my green-ness to ruby on rails is at fault here. I know its awesome and there is a lot to it and this is the first project I have done in it. So I am not sure what the correct solution is here, and I think its a vocabulary issue. Like what am i looking for?
Form helpers
Templates
Partials
etc etc… what is the best fit here? I realize in coding there is a lot of ways to skin a cat but I am not sure where to ask. Rereading this is getting subjective. Basically
I have a home controller that sets up things on a home page, turns out this data needs to be seen by the user at any given moment from any page in the app. Tried to move it to our navigation layout, its not going well. Is this the right approach or is there a better one?
One approach would be to use Cells. Essentially, a cell is a miniature controller that takes care of fetching data and rendering a view. It’s not quite a full-blown view, it’s a component which, similar to a partial, may be included into other views of your application – or even the layout, which is useful when you have something that appears on every page.
A classic example (which they implement on their homepage) is that of a shopping cart – it appears throughout your app but it needs to have some data set; turning it into a cell extracts both the querying and the rendering into a nicely-separated MVC unit.