Skip to content

Commit 8fa80eb

Browse files
committed
Added mobile number- issues with validations
1 parent 3991442 commit 8fa80eb

File tree

10 files changed

+49
-24
lines changed

10 files changed

+49
-24
lines changed

app/assets/stylesheets/custom.css.scss

+26-6
Original file line numberDiff line numberDiff line change
@@ -1680,14 +1680,14 @@ input,button,select,textarea
16801680

16811681
a
16821682
{
1683-
color: #2780e3;
1683+
color: #ff6600;
16841684
text-decoration: none;
16851685
}
16861686

16871687
a:hover,a:focus
16881688
{
1689-
color: #165ba8;
1690-
text-decoration: underline;
1689+
color: #ff6600;
1690+
text-decoration: none;
16911691
}
16921692

16931693
a:focus
@@ -3598,7 +3598,7 @@ output
35983598
.form-control
35993599
{
36003600
display: block;
3601-
width: 100%;
3601+
width: 60%;
36023602
height: 43px;
36033603
padding: 10px 18px;
36043604
font-size: 15px;
@@ -4178,8 +4178,8 @@ textarea.form-group-lg .form-control,select[multiple].form-group-lg .form-contro
41784178
.btn-default:hover,.btn-default:focus,.btn-default.focus,.btn-default:active,.btn-default.active,.open>.dropdown-toggle.btn-default
41794179
{
41804180
color: #ffffff;
4181-
background-color: #090909;
4182-
border-color: #040404;
4181+
background-color: #ff6600;
4182+
border-color: #ff6600;
41834183
}
41844184

41854185
.btn-default:active,.btn-default.active,.open>.dropdown-toggle.btn-default
@@ -6464,6 +6464,12 @@ a.thumbnail:hover,a.thumbnail:focus,a.thumbnail.active
64646464
border-color: #4e9f15;
64656465
color: #ffffff;
64666466
}
6467+
.alert-notice
6468+
{
6469+
background-color: #3fb618;
6470+
border-color: #4e9f15;
6471+
color: #ffffff;
6472+
}
64676473

64686474
.alert-success hr
64696475
{
@@ -6516,6 +6522,20 @@ a.thumbnail:hover,a.thumbnail:focus,a.thumbnail.active
65166522
color: #ffffff;
65176523
}
65186524

6525+
.alert-error
6526+
{
6527+
background-color: #FF0000;
6528+
border-color: #FF0000;
6529+
color: #ffffff;
6530+
}
6531+
6532+
.alert-alert
6533+
{
6534+
background-color: #FF0000;
6535+
border-color: #FF0000;
6536+
color: #ffffff;
6537+
}
6538+
65196539
.alert-danger hr
65206540
{
65216541
border-top-color: #d60054;

app/models/user.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ class User < ActiveRecord::Base
55
:recoverable, :rememberable, :trackable, :validatable
66

77
validates :user_name, uniqueness: true
8-
8+
validates :mobile,
9+
length: {minimum: 10, maximum: 10},
10+
:numericality => {:only_integer => true}
911
has_many :posts
1012
has_many :comments
1113
end

app/views/devise/registrations/edit.html.erb

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
<h2>Edit <%= resource_name.to_s.humanize %></h2>
1+
<center>
2+
<h2 style="padding: 1em;">Edit <%= resource_name.to_s.humanize %></h2>
23

34
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
45
<%= f.error_notification :error_html => { :class => "error"} %>
56

67
<div class="form-inputs">
78
<%= f.input :first_name, required: true, autofocus: true %>
89
<%= f.input :last_name, required: true, autofocus: true %>
9-
<%= f.input :user_name, required: true, autofocus: true %>
10+
<%= f.input :user_name, label: 'Username', required: true, autofocus: true %>
1011
<%= f.input :email, required: true, autofocus: true %>
12+
<%= f.input :mobile, label: 'Mobile No.', required: true, autofocus: true %>
1113

1214
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
1315
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
@@ -28,3 +30,6 @@
2830
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
2931

3032
<%= link_to "Back", :back %>
33+
<br>
34+
<br>
35+
</center>

app/views/devise/registrations/new.html.erb

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
<div class="formwrapper">
22
<center>
3-
<h1>Sign up</h2>
3+
<h1 style="padding: 1em;">Sign up</h2>
44

55
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
66
<%= f.error_notification %>
77

88
<div class="form-inputs">
99
<%= f.input :first_name, :placeholder => 'First Name', required: true, autofocus: true %>
10-
<br>
1110
<%= f.input :last_name, :placeholder => 'Last Name', required: true, autofocus: true %>
12-
<br>
1311
<%= f.input :user_name, :placeholder => 'Username', required: true, autofocus: true %>
14-
<br>
1512
<%= f.input :email, :placeholder => 'Email', required: true, autofocus: true %>
16-
<br>
13+
<%= f.input :mobile, :placeholder => 'Mobile No.', required: true, autofocus: true %>
1714
<%= f.input :password, :placeholder => 'Password', required: true %>
18-
<br>
1915
<%= f.input :password_confirmation, :placeholder => 'Confirm Password', required: true %>
20-
<br>
2116
</div>
2217

2318
<div class="form-actions">

app/views/devise/sessions/new.html.erb

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
<div class="formwrapper">
22
<center>
3-
<h1>Log in</h1>
3+
<h1 style="padding: 1em;">Log in</h1>
44

55
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
66
<div class="form-inputs">
77
<%= f.input :email, :placeholder => 'Email', required: false, autofocus: true %>
8-
<br>
98
<%= f.input :password, :placeholder => 'Password', required: false %>
10-
<br>
119
<%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
12-
<br>
1310
</div>
1411

1512
<div class="form-actions">
1613
<%= f.button :submit, "Log in" %>
1714
</div>
1815
<% end %>
19-
<br>
2016
<div class="bottom-links">
2117
<%= render "devise/shared/links" %>
2218
</div>

app/views/layouts/_messages.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% flash.each do |key, value| %>
2-
<div class="alert alert-<%= key %> alert-dismissible alert-success">
2+
<div class="alert alert-<%= key %> alert-dismissible">
33
<a href="#" data-dismiss="alert" class="close">×</a>
44
<ul>
55
<li>

app/views/layouts/application.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<ul class="nav navbar-nav">
1616
<% if user_signed_in? %>
1717
<li><%= link_to "Profile", current_user %></li>
18+
<li><%= link_to "Edit Profile", edit_user_registration_path %></li>
1819
<li><%= link_to "Log Out", destroy_user_session_path, :method => :delete %></li>
1920
<% else %>
2021
<li><%= link_to "Sign Up", new_user_registration_path %></li>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddMobileToUsers < ActiveRecord::Migration
2+
def change
3+
add_column :users, :mobile, :string
4+
end
5+
end

db/schema.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20150126102943) do
14+
ActiveRecord::Schema.define(version: 20150305132905) do
1515

1616
create_table "comments", force: true do |t|
1717
t.text "comment"
@@ -48,6 +48,7 @@
4848
t.string "first_name"
4949
t.string "last_name"
5050
t.string "user_name"
51+
t.string "mobile"
5152
end
5253

5354
add_index "users", ["email"], name: "index_users_on_email", unique: true
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12854
1+
19622

0 commit comments

Comments
 (0)