I am migrating a frontend webpage to the rails environment. I have used the Material Design Lite library to style my form fields. I have defined two routes till now: /home and /home/new. The /home page has a link which leads to /home/new.
When using the link to go to /home/new, the floating labels in the form fields are not getting rendered. But when I directly go to /home/new by typing in the address bar, all the styles get rendered properly.
How to fix this issue?
home\index.html.erb
<!DOCTYPE html>
<html lang="eng">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SMS scheduling site</title>
<%= stylesheet_link_tag "home.style" %>
</head>
<body>
<h1>Saved Campaigns</h1>
<p> <%= link_to 'Create New Campaign', "/home/new" %></p>
</body>
</html>
home/new.html.erb
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SMS scheduling site</title>
<%= stylesheet_link_tag "mdDateTimePicker" %>
<%= stylesheet_link_tag "style" %>
</head>
<body>
<div class="container-div">
<!-- Colored FAB button with ripple -->
<button id="fab" class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored">
<i class="material-icons">add</i>
</button>
<div class="demo-card-wide mdl-card mdl-shadow--2dp">
<div class="mdl-card__title" id="text-div">
<h2 id="title-text" class="mdl-card__title-text">CAMPAIGN</h2>
<br>
<br>
<span id="success">Success!</span>
</div>
<div class="mdl-card__supporting-text">
<form action="#">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="campaign-name">
<label class="mdl-textfield__label" for="phone-number-receiver">Campaign Name</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="phone-number-receiver">
<label class="mdl-textfield__label" for="phone-number-receiver">Phone Number for recipient</label>
<span class="mdl-textfield__error">Input is not a number!</span>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="start-date">
<label class="mdl-textfield__label" for="start-date" id="start-date-label">Enter start date</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="end-date">
<label class="mdl-textfield__label" for="end-date" id="end-date-label">Enter end date</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="start-time">
<label class="mdl-textfield__label" for="end-date" id="start-time-label">Enter time</label>
</div>
<div class="mdl-textfield mdl-js-textfield less-margin">
<textarea class="mdl-textfield__input" type="text" id="sms-msg" rows="8" columns="40"></textarea>
<label class="mdl-textfield__label" for="sms-msg">Text lines...</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="break-msg" value="1">
<label class="mdl-textfield__label" for="break-msg">Number of Pages</label>
</div>
</form>
</div>
</div>
</div>
<%= javascript_include_tag "mdDateTimePicker" %>
<%= javascript_include_tag "app" %>
</body>
</html>
routes.rb
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get '/home', to: 'home#index'
get '/home/new', to: 'home#new'
end
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>SmsScheduler</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag "https://fonts.googleapis.com/icon?family=Material+Icons" %>
<%= stylesheet_link_tag "https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en" %>
<%= stylesheet_link_tag "https://fonts.googleapis.com/css?family=Roboto+Mono" %>
</head>
<body>
<%= yield %>
</body>
</html>
application.js
//= require turbolinks
//= require_tree
//= require jquery
//= require jquery-ui
//= require moment
//= require material
//= require draggabilly.pkgd
application.css
/*
*= require_tree .
*= require_self
*= require jquery-ui
*= require material
*/

