I have a to do list function in my app which appears to be creating duplicate tasks every time I try to enter one. (You can see the error live at https://www.thestaysanemom.com/tasks with the username 'test#test.com' and password of 'password'.)
The app uses ajax to function, which I can only imagine is causing the error.
The create method is like this:
def create
#task = Task.new(task_params)
#task.user_id = current_user.id
if #task.save
respond_to do |format|
format.js
format.html
end
else
render :new
end
end
Here's the view where it all takes place:
<% if current_user %>
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-12">
<div class="content-box to-do">
<h2 class="font-script text-center">One-Time Tasks</h2>
<p class="text-center">These tasks are here to stay, until you complete them.</p>
<div id="onetime-todo"><%= render partial: 'items', locals: { task: #one_time } %></div>
<div id="onetime-done"><%= render partial: 'done', locals: { task: #one_time_done } %></div>
</div> <!-- content box -->
</div> <!-- col -->
<div class="col-xs-12 col-md-6 col-lg-4">
<div class="content-box to-do">
<h2 class="font-script text-center">Daily</h2>
<p class="text-center">These automatically uncheck at night so you have a fresh list in the morning.</p>
<div id="daily-todo"><%= render partial: 'items', locals: { task: #daily } %></div>
<div id="daily-done"><%= render partial: 'done', locals: { task: #daily_done } %></div>
</div> <!-- content box -->
</div> <!-- col -->
<div class="col-xs-12 col-md-6 col-lg-4">
<div class="content-box to-do">
<h2 class="font-script text-center">Weekly</h2>
<p class="text-center">These automatically uncheck Sunday night so you get a new list each Monday morning.</p>
<div id="weekly-todo"><%= render partial: 'items', locals: { task: #weekly } %></div>
<div id="weekly-done"><%= render partial: 'done', locals: { task: #weekly_done } %></div>
</div> <!-- content box -->
</div> <!-- col -->
<div class="col-xs-12 col-md-6 col-lg-4">
<div class="content-box to-do">
<h2 class="font-script text-center">Monthly</h2>
<p class="text-center">These automatically uncheck on the last day of the month so you start with a clean list each 1st.</p>
<div id="monthly-todo"><%= render partial: 'items', locals: { task: #monthly } %></div>
<div id="monthly-done"><%= render partial: 'done', locals: { task: #monthly_done } %></div>
</div> <!-- content box -->
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- container -->
<% end %> <!-- current_user -->
<script>
$(document).ready(function() {
$('.content-box').matchHeight();
});
</script>
Here's my create.js.erb:
$("#onetime-todo").html("<%= escape_javascript(render partial: 'items', locals: { task: #one_time }) %>")
$("#onetime-done").html("<%= escape_javascript(render partial: 'done', locals: { task: #one_time_done }) %>")
$("#daily-todo").html("<%= escape_javascript(render partial: 'items', locals: { task: #daily }) %>")
$("#daily-done").html("<%= escape_javascript(render partial: 'done', locals: { task: #daily_done }) %>")
$("#weekly-todo").html("<%= escape_javascript(render partial: 'items', locals: { task: #weekly }) %>")
$("#weekly-done").html("<%= escape_javascript(render partial: 'done', locals: { task: #weekly_done }) %>")
$("#monthly-todo").html("<%= escape_javascript(render partial: 'items', locals: { task: #monthly }) %>")
$("#monthly-done").html("<%= escape_javascript(render partial: 'done', locals: { task: #monthly_done }) %>")
$('#textField').val("");
Which renders _items.html.erb:
<div class="to-do-list taskWrapper" data-url="<%= sort_tasks_path %>">
<% task.each do |task| %>
<div id="<%= dom_id(task) %>">
<%= link_to task do %>
<p>
<%= fa_icon "bars", class: "color-neutral-light", style: "margin-right: 5px;" %>
<%= link_to check_task_path(task), method: :post, remote: true do %>
<%= fa_icon "square-o", style: "margin-right: 5px;" %>
<% end %>
<span id="task-show-hide">
<span class="font-serif">
<%= task.name %>
</span>
<span>
<%= link_to task_path(task), method: :delete, remote: true do %>
<%= fa_icon "remove", id: (task.id.to_s + "task"), style: "margin-left: 5px" %>
<% end %>
</span>
</span>
</p>
<% end %> <!-- dom id wrapper -->
</div>
<% end %> <!-- task each -->
</div>
<script>
$(document).on('ready page:load', function() {
$('.content-box').matchHeight();
$(".taskWrapper").sortable({
update: function(e, ui) {
var $that = $(e.target);
Rails.ajax({
url: $(this).data("url"),
type: "PATCH",
data: $that.sortable('serialize'),
});
console.log(ui.item.index())
}
});
});
</script>
And I don't think it matters, but for completion's sake here's the schema for tasks.
create_table "tasks", force: :cascade do |t|
t.string "name"
t.string "frequency"
t.boolean "completed", default: false
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "position"
t.index ["user_id"], name: "index_tasks_on_user_id"
end
Can anyone see why this is creating duplicates?
Additional Info: ERB Form Creation
<%= simple_form_for(#create_task, remote: true) do |f| %>
<div class="row padded">
<div class="col-xs-12 col-sm-9">
<%= f.text_field :name, id: "textField", placeholder: "What needs to get done?", class: "form-control" %>
</div>
<div class="col-xs-12 col-sm-3">
<%= f.select :frequency, options_for_select([["One-Time", "OneTime"],["Daily", "Daily"],["Weekly", "Weekly"],["Monthly", "Monthly"]]), {}, {class: "form-control"} %>
</div>
<div class="container text-center">
<div class="half-buffer"></div>
<%= f.button :submit, class: "btn btn-outline-secondary" %>
<div class="half-buffer"></div>
</div>
</div> <!-- row -->
<% end %>
ADDITIONAL INFORMATION
As requested, here are my required statements inside my application.js.erb:
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require popper
//= require magnific-popup
//= require jquery-ui
//= require froala_editor.min.js
//= require plugins/align.min.js
//= require plugins/char_counter.min.js
//= require plugins/code_beautifier.min.js
//= require plugins/code_view.min.js
//= require plugins/colors.min.js
//= require plugins/font_size.min.js
//= require plugins/fullscreen.min.js
//= require plugins/image.min.js
//= require plugins/image_manager.min.js
//= require plugins/inline_style.min.js
//= require plugins/line_breaker.min.js
//= require plugins/link.min.js
//= require plugins/lists.min.js
//= require plugins/paragraph_format.min.js
//= require plugins/paragraph_style.min.js
//= require plugins/quote.min.js
//= require plugins/special_characters.min.js
//= require plugins/url.min.js
** ADDED GEMFILE **
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.0'
gem 'rails', '~> 5.2.0'
gem 'puma', '~> 3.11'
gem 'puma_worker_killer'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jbuilder', '~> 2.5'
gem 'mini_magick'
gem 'jquery-rails'
gem 'devise'
gem 'bootsnap'
gem 'bootstrap', '~> 4.1.3'
gem 'jquery-ui-rails'
gem 'sprockets-rails'
gem 'bootstrap-sass'
gem 'bcrypt', '~> 3.1.7'
gem 'friendly_id', '~> 5.2.0'
gem 'stripe'
gem 'figaro'
gem 'magnific-popup-rails', '~> 1.1.0'
gem 'simple_form'
gem 'acts-as-taggable-on', '~> 6.0' #must be this version for Rails5
gem 'aws-sdk' , '~> 3'
gem 'aws-sdk-s3', require: false
gem 'simple_form_extension'
gem 'recaptcha', require: "recaptcha/rails"
gem 'font-awesome-rails'
gem 'trix-rails', require: 'trix'
gem 'rack-tracker'
gem 'high_voltage', '~> 3.1'
gem 'convertkit-ruby', require: 'convertkit'
gem 'dotenv-rails'
gem 'acts_as_list'
gem 'wysiwyg-rails'
gem 'font-awesome-sass'
gem 'will_paginate'
group :production do
gem 'pg', '~> 0.20.0'
end
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'sqlite3'
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'binding_of_caller'
gem 'better_errors'
end
group :test do
gem 'capybara', '>= 2.15', '< 4.0'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Your rails code looks fine, but your form is getting double-submitted when you submit. You should be able to see this in the Chrome dev tools as below.
Both of those references point to the application.js file, but different lines. It's hard to tell which libraries are catching the submit because the file is concatenated and doesn't include the debug information. Without seeing which JS files you're using (from application.js), I'd venture a guess that you might have both rails-ujs & jquery_ujs included which is causing the double submit.
Check the related question and answers here: Form submitted twice, due to :remote=>true
Update: You've definitely got both rails-ujs & jquery_ujs present in your compiled JS file. I think that's a good place to look. If you're on Rails 5 and using the jquery-rails gem you might look here: https://github.com/rails/jquery-rails#installation
If you are running Rails 5.1 and up, and if you have
included //= require rails-ujs, then jquery_ujs is not needed anymore
You just need to remove the //= require jquery_ujs line from your app/assets/javascripts/appplication.js file
Related
i want to create database in ruby on rails.
This worked fine in the development environment.
but upload AWS lightsail, this occurred error.
What's the problem?
below using gem
source 'https://rubygems.org'
gem 'kaminari'
gem 'faker'
gem 'carrierwave'
gem 'fog-aws'
gem 'mini_magick'
gem 'devise'
gem 'sunspot_rails'
gem "bootstrap_form", ">= 4.0.0.alpha1"
gem 'rails', '5.0.6'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'figaro'
gem 'sunspot_solr'
gem 'sqlite3'
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
below create controller
def create
#person = Person.new(params.require(:person).permit(:name, :phone, :relation, :user_id, :image))
if #person.save
redirect_to people_path
else
redirect_to new_person_path
end
end
below new.html.erb
<body class="main4">
<div class="container" style = "letter-spacing:-1px;">
<center><h2 class="mt-5">연락처 추가</h2></center>
<div style="font-weight: bold; display:flex; justify-content:center; margin-top: 10px; letter-spacing:-1px;">
<%= form_for :person, :html => { :multipart => true, name: "personForm", :onsubmit => "return validateform();"}, url: people_path do |f| %>
<div class="group">
<%= f.file_field :image %>
<span class="highlight"></span><span class="bar"></span>
</div>
<br/>
<div class="group">
<%= f.text_field :name , required: true %>
<span class="highlight"></span><span class="bar"></span>
<label>이름</label>
</div>
<br/>
<div class="group">
<%= f.number_field :phone , required: true %>
<span class="highlight"></span><span class="bar"></span>
<label>전화번호</label>
</div>
<br/>
<div class="group">
<span>관계    </span>
<%= f.select(:relation, ['가족', '친구', '지인', '직장동료', '거래처', '기타'], {:class => 'form-control'})%>
</div>
<%= f.hidden_field :user_id, value: current_user.id %>
<p style="text-align:right;"><%= f.button :추가, label: '추가', :class => 'btn btn-outline-light' %></p>
<% end %>
</div>
</div>
</div>
<script>
function validateform(){
var personName = document.personForm.person_name;
var personPhone = document.personForm.person_phone;
var personImage = document.personForm.person_image;
if(personName.value==""){
alert("이름이 입력되지 않았습니다.");
document.personForm.person_name.focus();
document.getElementById('person_name').select();
return false;
}
else if(personName.value.length > 4){
alert("이름은 4글자 이하로 작성해주세요.");
document.personForm.person_name.focus();
document.getElementById('person_name').select();
return false;
}
else if(personPhone.value==""){
alert("전화번호가 입력되지 않았습니다.");
document.personForm.person_phone.focus();
document.getElementById('person_phone').select();
return false;
}
}
</script>
</body>
below error scene in lightsail
enter image description here
Again, it works in the development environment, but if you put it on the AWS lightsail, i'm get this error
I want to implement a dual list box in a form using rails 4 that gets the column names from another table
I have googled for some examples and so far i have tried the example below but with no success. I just need a simple way to implement a dual list box that gets the column name it doesn't have to be this although this is looks pretty
http://geodan.github.io/duallistbox/sample-100.html.
Here is application.js
//= require bootstrap-sprockets
//= require jquery
//= require jquery_ujs
//= require bootstrap.min
//= require bootstrap
//= require turbolinks
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap3
//= require_tree .
i have downloaded dual-list-box.js to my assets/javacrtipt from https://github.com/Geodan/DualListBox/
Here is my data_set.coffe
ready = ->
$('dualListBox').DualListBox();
return
$(document).ready ready
Here is my _form.html.erb
<%= form_for(#data_set) do |f| %>
<% if #data_set.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(#data_set.errors.count, "error") %> prohibited this data_set from being saved:</h2>
<ul>
<% #data_set.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name ,class:'form-control' %>
</div>
<div class="panel panel-default">
<div class="panel-heading">
Select Features
</div>
<div class="panel-body">
<select id="dualListBox">
</div>
</div>
<div class="actions">
<%= f.submit :class =>"btn btn-default" %>
</div>
<% end %>
My gem file
source 'https://rubygems.org'
gem 'rails', '4.2.5.1'
gem 'pg'
gem 'rails_12factor', group: :production
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'tzinfo-data', platforms: [:mingw, :mswin]
gem 'rails_refactor'
gem 'bcrypt', platforms: :ruby
gem 'bootstrap-sass'
gem 'sprockets-rails', '2.3.3'
gem 'devise'
gem 'jquery-datatables-rails', '~> 1.12.2'
EDIT:
my final result was this:
I am having problems with compatibility between bootstrap sprockets and jquery, so fonts are not loading,i have decided for now to stop working on this component.
$(document).ready ->
ready()
ready = ->
$('#dualListBox').DualListBox()
You have an element with id "dualListBox" so you need to use '#' in the jQuery selector.
I've created a new Rails project, added gem 'simple_form', '~> 3.2', '>= 3.2.1' to my gemfile and configured my project to use Bower, than added Bootstrap via Bower.
Even though I used rails generate simple_form:install --bootstrap, the form elements don't get the Bootstrap css classes.
I've checked the HTML after the page is rendered and the Bootstrap css/js are there. Do I need to use Bootstrap gem instead of Bower package??
Here is the .bowerrc file:
{
"directory": "vendor/assets/components"
}
bower.json
{
"name": "TesteKlipbox",
"authors": [
"Juliano Nunes"
],
"description": "",
"main": "",
"license": "MIT",
"homepage": "",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"vendor/assets/components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "^3.3.6"
}
}
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'simple_form', '~> 3.2', '>= 3.2.1'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
And the form code:
<%= simple_form_for(#noticia, html: { class: 'form-horizontal' }) do |f| %>
<% if #noticia.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(#noticia.errors.count, "error") %> erros impediram que esta notícia fosse salva:</h2>
<ul>
<% #noticia.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :titulo %><br>
<%= f.text_field :titulo %>
</div>
<div class="field">
<%= f.label :texto %><br>
<%= f.text_area :texto %>
</div>
<div class="field">
<%= f.label :data %><br>
<%= f.datetime_select :data %>
</div>
<div class="field">
<%= f.label :tags %><br>
<%= f.text_field :tags %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
UPDATE
Another user has already answered the question. My mistake was that I didn't replace f.text_field by f.input. It has nothing to do with the suggested bootstrap theme question.
To start using Simple Form you just have to use the helper it
provides:
<%= simple_form_for #user do |f| %>
<%= f.input :username %>
<%= f.input :password %>
<%= f.button :submit %>
<% end %>
The helper being f.input instead of the Rails helper(s) such as f.text_field, f.text_area etc. See Simple_Form Usage and Rails Form Helpers.
The below image shows the first input using f.text_field and the second using f.input.
Make sure that bootstrap is stored in the correct location:
bootstrap.min.css as well as bootstrap.css,
bootstrap.min.js and bootstrap.js,
all need to be located in app/assets/stylesheets and app/assets/javascripts respectively.
Add *= require bootstrap to app/assets/stylesheets/application.css and,
add //= require bootstrap to app/assets/javascripts/application.js
Can anybody please solve me one issue regarding bootstrap using in ROR.
Issue:
I have integrated gem "'bootstrap-sass', '3.2.0.2'" in my gem file.After adding some bootstrap navigation code in application.html.erb,it is showing one nice bootstrap navigation bar.If i am doing some changes in style sheet and refreshes the page it is splitting means the nav menu lists is not coming in inline and next time onward it is repeating.Actually i want the original nav bootstrap bar even if I did any changes in style sheet.
Please check my below code snippets and make it correct.
My codes are as follows:
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.19'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'bootstrap-sass', '3.2.0.2'
homes.css.scss
#import "bootstrap-sprockets";
#import "bootstrap";
body {
padding-top: 60px;
}
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>LibraryManagement</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<header class="navbar navbar-fixed-top navbar-default">
<div class="container">
<%= link_to "Library Management System", '#', id: "logo" %>
<nav>
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", '#' %></li>
<li><%= link_to "Books", '#' %></li>
<li><%= link_to "Member Entry", '#' %></li>
<li><%= link_to "Admin Login", '#' %></li>
</ul>
</nav>
</div>
</header>
<div class="container">
<%= yield %>
</div>
</body>
</html>
homes/index.html.erb
<h1>Index page</h1>
Please help me.Thanks in advance.
I'm new to Rails.
I've been tring bootstrap-timepicker-rails gem in my Rails4 application but it's doesn't work.
https://github.com/tispratik/bootstrap-timepicker-rails
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem 'twitter-bootstrap-rails'
gem 'bootstrap-timepicker-rails'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-timepicker
//= require_tree .
//= require_self
$('.t_picker').timepicker()
application.css
*= require_self
*= require bootstrap-timepicker
*= require_tree .
/event/_form.html.erb
<%= form_for(#event) do |f| %>
<% if #event.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(#event.errors.count, "error") %> prohibited this event from being saved:</h2>
<ul>
<% #event.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :location %><br>
<%= f.text_field :location %>
</div>
<div class="field">
<%= f.fields_for :schedules do |sch| %>
<%= sch.time_field :start %>
<%= sch.time_field :end %>
<%= sch.text_field :description %>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
I don't know if you still need this, but I made it work for me (Rails 4 app) by using the 'modal' template & setting specifically the id of my field, like this:
=f.input :time, as: :string, input_html: { class: 'bootstrap-timepicker', :id => 'time'}
& in the script, like this:
$('#time').timepicker({
minuteStep: 15,
etc etc..
Hope that helps :)
Try changing this:
<%= sch.time_field :start %>
<%= sch.time_field :end %>
to this:
<%= sch.time_field :start, class: 't_picker' %>
<%= sch.time_field :end, class: 't_picker' %>
Maybe it will help.