Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ROR simple-form datepicker

I have just finished building my first ROR app, and I am really in love with the way everything came out except for these big ugly clunky date selectors on my page. Early on in development I installed the simple_form gem to handle the forms. Now that I am done, I really want to make those clunky date selectors into textfields with datepickers. I have followed a bunch of dead ends, I installed the simple-form-datepicker gem, and I am trying to follow the jquery-ui-dateselector guides, but am having to luck.

My application.js file looks like

     //= require jquery
     //= require jquery_ujs
     //= require jquery.ui.all
     //= require turbolinks
     //= require_tree .

     $("input.datepicker").each(function(input) {
     $(this).datepicker({
     dateFormat: "yy-mm-dd",
     altField: $(this).next()
      })

I included the *require jquery in my css file as well. My form code looks like this

  <%= f.input :assigned_date, :as :datepicker %>

Am getting an error that says

   /home/jps/gtf_app/app/views/investigations/_form.html.erb:50: syntax error, unexpected ':', expecting ')' ...( f.input :assigned_date, :as :datepicker );@output_buffer.s... ... ^

Really this is the last thing I have to do before I feel comfortable saying I am done working on this application. Everything is so beautiful and awesome except for these ugly date selectors. Earlier in my app simple_form gave me a headache with radio buttons and then again with dropdown selectors. I am starting to think simpleform maybe isnt so simple. Any help would be greatly appreciated.

Thanks

like image 733
jpstearns Avatar asked Feb 06 '26 21:02

jpstearns


1 Answers

Your syntax is invalid, you want:

<%= f.input :assigned_date, as: :datepicker %>

or

<%= f.input :assigned_date, :as => :datepicker %>
like image 77
Brad Werth Avatar answered Feb 09 '26 11:02

Brad Werth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!