I am using an instance variable, @week_starting, to display a table of the current week and have Twitter Bootstrap icons < > that I want to decrement / increment the week upon being clicked, then reload the current page. Suspect that the problem is partly in how I'm defining the variable in the controller. Won't this constantly be re-written? How can I fix this?
My instance variable in the controller is:
@week_starting = Date.today.at_beginning_of_week
This is the code I'm using but clearly it is not correct.
[Helper Functions]
def increment_week(week_starting)
week_starting += 7
end
def decrement_week(week_starting)
week_starting -= 7
end
[View]
<%= link_to user_path(current_user, view: "prod"), {:onclick => increment_week(@week_starting)} do %>
<i class="icon-chevron-right pull-right"></i>
<% end %>
HTML created:
<a href="/users/4?view=prod" onclick="2013-05-27">
<i class="icon-chevron-right pull-right"></i>
</a>