hello,
I would like to know how could it be possible to set a css class as
parameter and a default one.
For instance class=“active” will be located on the first, second
lines, depending on the action.
application.html.erb:
Tasks
Categories
Calendar
Eisenhower matrix
Any help would be highly appreciated.
bye
For instance class=“active” will be located on the first, second
lines, depending on the action.
application.html.erb:
things.each_with_index do |thing, index|
>Tasks
That’s just the sketch of the behaviors - but you must clean it up. The
2
and the ‘foo’ should appear in a table, preferably inside the thing
model.
Controllers should have the minimum possible logical statements, and
View
should have less.
Tasks
Thanks for helping.
Does it mean that I need to create a get_class function in each model
(tasks, categories, calendar …)?
Thanks for your help.
You could use a method call from a helper.
For your example:
in the application.html.erb
Tasks
Categories
Calendar
Eisenhower
matrix
then in the application_helper.rb
def get_class(active_action)
“active” if @active_action == active_action
end
then in your actions set the @active_action variable
for your default, you could set the @active_action in the
application.rb controller, then it will be overwritten if some action
specifically overrides the variable
If you are trying to highlight the active tab a good way of doing it is
by giving all the tabs an id as well as a body id for each of the pages
that the tabs exist on. Once you do this you have control of the active
tab style.
ex.
- ...
- ...
...
css
the active tab
body#tasks li#task_tab, body#categories li#category_tab … {
…
}
the inactive tabs
ul#tabs { … }