DavyJonesLocker / client_side_validations

Client Side Validations made easy for Ruby on Rails
MIT License
2.69k stars 405 forks source link

<script> not generating #667

Closed marksoden closed 8 years ago

marksoden commented 8 years ago

Hi,

I'm battling to get this gem to work correctly, the script doesn't seam to generate, using rails 4.2.6

gemfile:

gem 'client_side_validations' initializer: un commented line 14 - 20

model:

validates :email, :first_name, :last_name, presence: true

application.js

//= require jquery //= require jquery_ujs //= require jquery-ui //= require wysihtml5 //= require parser_rules/advanced //= require rails.validations //= require_tree .

html (code):

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Fujifilm Xperience</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <%= stylesheet_link_tag    'application', media: 'all' %>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">  
  <%= javascript_include_tag 'application' %>
  <%= csrf_meta_tags %>
</head>
<body>
<div class="mobileblackout" style="display: none:"></div>
<nav class="navbar navbar-default navbar-fixed-top ">
  <div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>              
      </button>
      <a class="navbar-brand" href="/"><img src="/assets/fuji-logo.png" /></a>
    </div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">        

      <ul class="nav navbar-nav navbar-right">
        <li><a href="/#excursions">Excursions</a></li>
        <li><a href="/#workshops">Workshops</a></li>
        <% if current_user %>

            <li><a href="/booking">My Bookings</a></li>
            <li><a href="/profile">Profile</a></li>
            <% if current_user.admin %>             
                <li><a href="/admin">admin</a></li> 

            <% end %>           
            <li><a href="/logout"><i class="fa fa-sign-out"></i> Log Out</a></li>
            <li class="hidden-xs"><a href="#">Hi <%= current_user.first_name %></a></li>
        <% else %>          
            <li ><button class="btn btn-green open-login">Log in <i class="fa fa-chevron-down "></i></button>
                <div class="login-box thumbnail"  style="display:none;">
                    <%= form_tag sessions_path, remote: true do %>
                    <div class="close cls-login"><i class="fa fa-times"></i></div>
                    <p class="note" id="login-msg"></p>
                    <div class="form-group">
                        <label for="email" >Email</label>
                        <%= text_field_tag :email, '', :class => 'form-control' %>

                    </div>
                    <div class="form-group">
                        <label for="password" >Password</label>
                        <%= password_field_tag :password, '', :class => 'form-control' %>
                        <div class="sub-text"><%= check_box_tag :remember_me, 1, params[:remember_me], :class => 'rem-me-input' %> Remeber Me? | <a class="open-forgot">forgotten password?</a></div>
                    </div>
                    <button type="submit" class="btn btn-red">Log In</button> or <a data-toggle="modal" data-target="#userForm" id="newUser" class="cls-login">register</a>

                    <% end %>
                </div>
                <div class="forgot-box thumbnail"  style="display:none;">
                    <%= form_tag password_resets_path, :method => :post, remote: true do %>
                      <div class="close cls-forgot"><i class="fa fa-times"></i></div>
                        <p class="note" id="forgot-msg">To reset you password please provide your email address, and follow the instrcutions in your email</p>
                        <div class="form-group">
                            <label for="email" >Email</label>
                            <%= text_field_tag :email, params[:email], :class => 'form-control' %>

                        </div>                    

                      <button type="submit" class="btn btn-red">Reset Password</button> or <a class="open-login">log in</a>
                    <% end %>               
                </div>
                <div class="msg-box thumbnail" style="display:none;"></div>
            </li>
         <% end %>
      </ul>

    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

        <div style="margin-top:90px;"></div>  
        <% if @user.errors.any? %>
            <div id="error_explanation">
              <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

              <ul>
              <% @user.errors.full_messages.each do |message| %>
                <li><%= message %></li>
              <% end %>
              </ul>
            </div>
          <% end %>
            <%= form_tag @user, validate: true,   :class => 'form-horizontal' do  %>

                        <div class="form-group">
                            <label for="user_name" class="col-sm-3 control-label">Name</label>
                            <div class="col-sm-9">
                                <input type="text" id="user_first_name"  class="form-control" name="user[first_name]">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="last_name" class="col-sm-3 control-label">Last name</label>
                            <div class="col-sm-9">
                                <input type="text" id="user_last_name"  class="form-control" name="user[last_name]">
                            </div>
                        </div>                        
                        <div class="form-group">
                            <label for="contact_tel" class="col-sm-3 control-label">Contact No</label>
                            <div class="col-sm-9">
                                <input type="text" id="user_contact_tel"  class="form-control" name="user[contact_tel]">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="user_email" class="col-sm-3 control-label">Email</label>
                            <div class="col-sm-9">
                                <input type="email" id="user_email"  class="form-control" name="user[email]">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="user_password" class="col-sm-3 control-label">Password</label>
                            <div class="col-sm-9">
                                <input type="password" id="user_password"  class="form-control" name="user[password]">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="user_password_conf" class="col-sm-3 control-label">Password Confirm</label>
                            <div class="col-sm-9">
                                <input type="password" id="user_password_conf"  class="form-control" name="user[password_confirmation]">
                            </div>
                        </div>
                       </div>
            <button type="submit" class="btn btn-default" >Create</button>

         <% end %>

</div>
</body>
</html>

any help would be much appreciated.

thanks Mark

tagliala commented 8 years ago

rendered html (Post submit):

could you please copy and paste rendered html source inside a proper markup block?

eg:

<html>
</html>

Take a look here: https://guides.github.com/features/mastering-markdown/

marksoden commented 8 years ago

updated

tagliala commented 8 years ago

@marks-za sorry, I didn't notice the error before

<%= form_tag

form_tag is not supported, you must use form_for