Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4f33a3e
updated gem file
Dec 1, 2015
3bd0c75
ignore bundle dependencies
Dec 2, 2015
154e42c
add image links to shapes view
Dec 2, 2015
d3cb5bc
added pet, color, and shape image to view
Dec 2, 2015
2befe00
uppercased value
Dec 2, 2015
2eded36
Changed last name to Name
Dec 2, 2015
4090599
created drop-down menu for color and shape, removed color column from…
Dec 3, 2015
a500cff
added Color.all and Shape.all actions to pet controller
Dec 3, 2015
f9b33ce
styled background hex value in colors#show
Dec 3, 2015
ebe97d0
hex value display across whole page in pets show#
Dec 3, 2015
78523f8
called @colors and @shapes method
Dec 4, 2015
5a6c58c
put back color attribute on pets view
Dec 4, 2015
3098992
changed color and shape selection to radio button pets new#
Dec 4, 2015
be499d7
replaced collection_radio_button with stylized html pets#form
Dec 4, 2015
d05cd4f
replaced shapes collection_radio_button with stylized html pets#form
Dec 4, 2015
869ecea
added @colors and @shapes pets edit controller
Dec 4, 2015
984ffe8
added shape image to pets show#
Dec 4, 2015
67265c5
added hex_value to pets show#
Dec 4, 2015
df731d6
added shape image to shapes show#
Dec 4, 2015
f2251da
Fix pet#form color and shape fields
dmzza Dec 5, 2015
25b6dfb
Generate a lucky number on the Pet model, add it to pets#index
dmzza Dec 5, 2015
8596e09
Merge pull request #9 from dmzza/feature/lucky-number
Dec 7, 2015
49d6307
added current pet color background to shape radio button pet#edit
Dec 7, 2015
6a2cad2
set default color attribute for pets#new
Dec 7, 2015
be2adce
set default color attribute for pets#new
Dec 7, 2015
3b07bbd
redirect pets#update to pets#edit instead of pets#show
Dec 7, 2015
b645039
change color and shape attributes with one click
Dec 7, 2015
f16890f
rendered pets#edit with the pet on the left half, and the form on the…
Dec 7, 2015
91f50ee
set pet-render and pet-form to take up half the screen pets#edit
Dec 7, 2015
6c91921
set color to only inside shapes pet#edit
Dec 7, 2015
a2b2c94
removed button background color, margins and padding pets#edit
Dec 7, 2015
1bd68e5
switched pet shape and color buttons pets/edit#
Dec 10, 2015
176a795
turned color buttons into circles
Dec 10, 2015
be4a94f
added padding and increased margin header pets/edit#
Dec 10, 2015
6531bd3
floated color and shape button
Dec 11, 2015
d8836a5
adding padding color buttons pets/edit#
Dec 11, 2015
3859db4
made selected color larger pets/edit#
Dec 11, 2015
b7d6db3
moved chubbyy rendered closer to the center pets/edit#
Dec 11, 2015
5336a5c
gem file update
Dec 13, 2015
fa33279
set register and login url path
Dec 18, 2015
7b8f114
fix typo
dmzza Dec 19, 2015
4bc5c99
let registered users manage everything
dmzza Dec 19, 2015
100d86b
devise_scope has to be user, added devise alerts
Dec 22, 2015
be5fe6a
gem update
Dec 30, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# Ignore bundler config.
/.bundle
/vendor/bundle

# Ignore the default SQLite database.
/db/*.sqlite3
Expand Down
50 changes: 26 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ GEM
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (6.0.2)
byebug (8.2.1)
cancancan (1.13.1)
coffee-rails (4.1.0)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
coffee-script-source (1.10.0)
concurrent-ruby (1.0.0)
debug_inspector (0.0.2)
devise (3.5.2)
devise (3.5.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
Expand All @@ -63,8 +64,8 @@ GEM
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.3.2)
activesupport (>= 3.0.0, < 5)
jbuilder (2.4.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-rails (4.0.5)
rails-dom-testing (~> 1.0)
Expand All @@ -75,14 +76,14 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.6.2)
mini_portile (0.6.2)
minitest (5.8.1)
mime-types (2.99)
mini_portile2 (2.0.0)
minitest (5.8.3)
multi_json (1.11.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
nokogiri (1.6.7.1)
mini_portile2 (~> 2.0.0.rc2)
orm_adapter (0.5.0)
pg (0.18.3)
pg (0.18.4)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
Expand Down Expand Up @@ -116,11 +117,11 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
rdoc (4.2.1)
json (~> 1.4)
responders (2.1.0)
railties (>= 4.2.0, < 5)
sass (3.4.19)
responders (2.1.1)
railties (>= 4.2.0, < 5.1)
sass (3.4.20)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
Expand All @@ -130,13 +131,14 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (1.4.0)
sprockets (3.4.0)
spring (1.6.1)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sprockets-rails (3.0.0)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
Expand All @@ -147,7 +149,7 @@ GEM
uglifier (2.7.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
warden (1.2.3)
warden (1.2.4)
rack (>= 1.0)
web-console (2.2.1)
activemodel (>= 4.0)
Expand Down
11 changes: 10 additions & 1 deletion app/controllers/pets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ def show
# GET /pets/new
def new
@pet = Pet.new
@pet.color = Color.first
@colors = Color.all
@shapes = Shape.all
end

# GET /pets/1/edit
def edit
@colors = Color.all
@shapes = Shape.all
@colors.each do |color|
if @pet.color.id == color.id
end
end
end

# POST /pets
Expand All @@ -42,7 +51,7 @@ def create
def update
respond_to do |format|
if @pet.update(pet_params)
format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }
format.html { redirect_to edit_pet_url(@pet), notice: 'Pet was successfully updated.' }
format.json { render :show, status: :ok, location: @pet }
else
format.html { render :edit }
Expand Down
4 changes: 4 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ def initialize(user)
user ||= User.new # guest user (not logged in)
if user.id?
can :manage, Campaign
can :manage, Pet
can :manage, Color
can :manage, Shape
can :manage, User
else
can :read, Campaign
end
Expand Down
9 changes: 9 additions & 0 deletions app/models/pet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@ def first_name
def full_name
first_name + " " + last_name
end

def expression_id
3 # lacking a model for now, default to the highest possible ID
end

def lucky_number
binary_string = ("%05b" % color_id) + ("%03b" % shape_id) + ("%02b" % expression_id)
binary_string.to_i(2)
end
end
4 changes: 2 additions & 2 deletions app/views/colors/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<table>
<thead>
<tr>
<th>Hex value</th>
<th>Hex Value</th>
<th colspan="3"></th>
</tr>
</thead>

<tbody>
<% @colors.each do |color| %>
<tr>
<td bgcolor="#<%= color.hex_value %>"><%= color.hex_value %></td>
<td bgcolor="#<%= color.hex_value %>"></td>
<td><%= link_to 'Show', color %></td>
<td><%= link_to 'Edit', edit_color_path(color) %></td>
<td><%= link_to 'Destroy', color, method: :delete, data: { confirm: 'Are you sure?' } %></td>
Expand Down
6 changes: 6 additions & 0 deletions app/views/colors/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<style>
body {
background: #<%= @color.hex_value %>;
}
</style>

<p id="notice"><%= notice %></p>

<p>
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<%= csrf_meta_tags %>
</head>
<body>

<span class="notice"><%= notice %></span>
<span class="alert"><%= alert %></span>
<%= yield %>

</body>
Expand Down
35 changes: 19 additions & 16 deletions app/views/pets/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@
</div>
<% end %>

<div class="field">
<%= f.label :color_id %><br>
<%= f.text_field :color_id %>
</div>
<div class="field">
<%= f.label :shape_id %><br>
<%= f.text_field :shape_id %>
</div>
<div class="field">
<%= f.label :last_name %><br>
<%= f.text_field :last_name %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<% @colors.each do |color| %>
<input type="radio" value="<%= color.id %>" name="pet[color_id]" id="pet_color_id_<%= color.id %>"/>
<label style="background-color:#<%= color.hex_value %>" for="pet_color_id_<%= color.id %>"><%= color.hex_value %></label>
<% end %>
<br>
<% @shapes.each do |shape| %>
<input type="radio" value="<%= shape.id %>" name="pet[shape_id]" id="pet_shape_id_<%= shape.id %>" />
<label style="background-color:#<%= @pet.color.hex_value %>" for="pet_shape_id_<%= shape.id %>"><%= image_tag(shape.image)%></label>
<% end %>
<br>

<div class="field">
<%= f.label :last_name %><br>
<%= f.text_field :last_name %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
92 changes: 89 additions & 3 deletions app/views/pets/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,92 @@
<h1>Editing Pet</h1>
<h1>Create your own Chubbyy 🙃</h1>

<%= render 'form' %>
<style>
h1 {
font-family: "Helvetica-Neue", "Helvatica", helvetica, arial, sans-serif;
margin: 40px;
font-size: 24pt;
line-height: normal;
padding-bottom: 30px;
}
img.shape {
background-color:#<%= @pet.color.hex_value %>;
}
div.pet-render {
float: left;
width: 50%;
margin-top: 80px;
}
div.pet-form {
float: left;
width: 50%;
}
button {
border: 0;
padding: 15px;
background-color: white;
}
.color-button div {
display: block;
width: 40px;
height: 40px;
border-radius: 20px;
border-style: solid;
border-width: 0px;
}
.color-button {
float: left;

<%= link_to 'Show', @pet %> |
}
.shape-button img {
width: 110px;
}
.shape-button {
float: left;
}
.selected {
padding:11px;
}
.selected div {
border-width: 4px;
border-color: black;
border-radius: 24px;
}
</style>

<div class="pet-render">
<%= image_tag(@pet.shape.image, class:"shape") %>
</div>

<div class="pet-form">

<% @shapes.each do |shape| %>

<%= form_for(@pet) do |f| %>
<input type="hidden" value="<%= shape.id %>"
name="pet[shape_id]"
id="pet_shape_id_<%= shape.id %>"/>
<button class="shape-button" type="submit" name="commit">
<%= image_tag(shape.image, class:"shape")%></button>

<% end %>
<% end %>

<div style="clear:left;"></div>

<% @colors.each do |color| %>

<%= form_for(@pet) do |f| %>
<input type="hidden" value="<%= color.id %>"
name="pet[color_id]"
id="pet_color_id_<%= color.id %>"/>
<button class="color-button<% if @pet.color.id == color.id %> selected<% end %>" type="submit" name="commit">
<div style="background-color:#<%= color.hex_value %>;border-color:#<%= color.hex_value %>;"
for="pet_color_id_<%= color.id %>"></div></button>

<% end %>
<% end %>

</div>

<%= link_to 'Show', @pet %>
<%= link_to 'Back', pets_path %>
8 changes: 5 additions & 3 deletions app/views/pets/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
<tr>
<th>Color</th>
<th>Shape</th>
<th>Last name</th>
<th>Name</th>
<th>Lucky Number</th>
<th colspan="3"></th>
</tr>
</thead>

<tbody>
<% @pets.each do |pet| %>
<tr>
<td bgcolor="#<%= pet.color.hex_value %>"><%= pet.color %></td>
<td><%= pet.shape %></td>
<td bgcolor="#<%= pet.color.hex_value %>"></td>
<td bgcolor="#<%= pet.color.hex_value %>"><%= image_tag(pet.shape.image)%></td>
<td><%= pet.full_name %></td>
<td><%= pet.lucky_number %></td>
<td><%= link_to 'Show', pet %></td>
<td><%= link_to 'Edit', edit_pet_path(pet) %></td>
<td><%= link_to 'Destroy', pet, method: :delete, data: { confirm: 'Are you sure?' } %></td>
Expand Down
4 changes: 2 additions & 2 deletions app/views/pets/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<p>
<strong>Color:</strong>
<%= @pet.color %>
<%= @pet.color.hex_value %>
</p>

<p>
<strong>Shape:</strong>
<%= @pet.shape %>
<%= image_tag(@pet.shape.image)%>
</p>

<p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shapes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<% @shapes.each do |shape| %>
<tr>
<td><%= shape.name %></td>
<td><%= shape.image %></td>
<td><%= image_tag(shape.image)%></td>
<td><%= link_to 'Show', shape %></td>
<td><%= link_to 'Edit', edit_shape_path(shape) %></td>
<td><%= link_to 'Destroy', shape, method: :delete, data: { confirm: 'Are you sure?' } %></td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shapes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<p>
<strong>Image:</strong>
<%= @shape.image %>
<%= image_tag(@shape.image)%>
</p>

<%= link_to 'Edit', edit_shape_path(@shape) %> |
Expand Down
Loading