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?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ec68a0feb6e62a436b1e285e7f1a3d3d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment