Matthew Bins
Matthew Bins

Reputation: 51

I want to have a variable increment when I click the link_to?

.col-md-2.col-sm-12.arrow_container{:style => "text-align:right;"}
  - if Date > 0
    = link_to movies_path(Date -= 1) do
      %i.fa.fa-caret-left
  - else
    %i.fa.fa-caret-left

/my display date code/

.col-md-2.col-sm-12.arrow_container{:style => "text=align:left;"}
  = link_to movies_path(Date += 1) do
    %i.fa.fa-caret-right

here's my code I want this button to be disabled when I am on the current date. When I hit the right arrow. I want the variable Date to increment by 1 and then the left arrow will be available. Right now I am getting an error for.

dynamic constant assignment ... = link_to movies_path(Date -= 1) do 

Upvotes: 1

Views: 68

Answers (1)

Daniel
Daniel

Reputation: 899

You could try to put the increment or decrement in the if condition statement - if date > 0 && date -= 1 = link_to movies_path(date) do

By the way, the variable should better be lower case.

Upvotes: 1

Related Questions