I'm very new to javascript so don't judge hard (any suggestions or comments would be highly appreciated).
I have a form in my rails app (haml file):
= simple_form_for(@book, remote: true) do |f| .row .form-group = f.input :book_title, as: :string, label: "Title of a book" %br = f.input :pages_number, as: :string, label: "Number of pages" %br .form-actions = f.button :submit, "Create", class: "btn btn-success" = link_to t('buttons.cancel'), '#', onclick: "$.modal.close()", class: 'btn btn-warning pull-right'
The action in controller which opens a form:
def new @book = Book.new end
The action in controller which saves a form:
def create end
What I'm trying to do is check whether input number of pages is bigger than 10. I want to create a confirm box.
I was trying to save @pages_number = params[:pages_number] in create action, and use data: (@pages_number < 10 ? { confirm: "Are you sure?" } : nil) in the view, but it didn't work.
Do I need to use Javascript in this case?