diff --git a/.gitignore b/.gitignore index 050c9d9..827620e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # Ignore bundler config. /.bundle +/vendor/bundle # Ignore the default SQLite database. /db/*.sqlite3 diff --git a/Gemfile.lock b/Gemfile.lock index e06038e..4b9c463 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/app/controllers/pets_controller.rb b/app/controllers/pets_controller.rb index 57497b0..5b74eae 100644 --- a/app/controllers/pets_controller.rb +++ b/app/controllers/pets_controller.rb @@ -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 @@ -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 } diff --git a/app/models/ability.rb b/app/models/ability.rb index daf06e7..cb4b023 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 diff --git a/app/models/pet.rb b/app/models/pet.rb index 13c8a55..5f6b5a4 100644 --- a/app/models/pet.rb +++ b/app/models/pet.rb @@ -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 diff --git a/app/views/colors/index.html.erb b/app/views/colors/index.html.erb index e857550..5d0e5f2 100644 --- a/app/views/colors/index.html.erb +++ b/app/views/colors/index.html.erb @@ -5,7 +5,7 @@ - + @@ -13,7 +13,7 @@ <% @colors.each do |color| %> - + diff --git a/app/views/colors/show.html.erb b/app/views/colors/show.html.erb index 47fce7c..52be820 100644 --- a/app/views/colors/show.html.erb +++ b/app/views/colors/show.html.erb @@ -1,3 +1,9 @@ + +

<%= notice %>

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c85c2bf..afc4d33 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,7 +10,8 @@ <%= csrf_meta_tags %> - + <%= notice %> + <%= alert %> <%= yield %> diff --git a/app/views/pets/_form.html.erb b/app/views/pets/_form.html.erb index 429f415..02cb023 100644 --- a/app/views/pets/_form.html.erb +++ b/app/views/pets/_form.html.erb @@ -11,19 +11,22 @@ <% end %> -

- <%= f.label :color_id %>
- <%= f.text_field :color_id %> -
-
- <%= f.label :shape_id %>
- <%= f.text_field :shape_id %> -
-
- <%= f.label :last_name %>
- <%= f.text_field :last_name %> -
-
- <%= f.submit %> -
-<% end %> + <% @colors.each do |color| %> + + + <% end %> +
+ <% @shapes.each do |shape| %> + + + <% end %> +
+ +
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name %> +
+
+ <%= f.submit %> +
+ <% end %> diff --git a/app/views/pets/edit.html.erb b/app/views/pets/edit.html.erb index 65502cc..35cc539 100644 --- a/app/views/pets/edit.html.erb +++ b/app/views/pets/edit.html.erb @@ -1,6 +1,92 @@ -

Editing Pet

+

Create your own Chubbyy 🙃

-<%= render 'form' %> + + +
+ <%= image_tag(@pet.shape.image, class:"shape") %> +
+ +
+ + <% @shapes.each do |shape| %> + + <%= form_for(@pet) do |f| %> + + + + <% end %> + <% end %> + +
+ + <% @colors.each do |color| %> + + <%= form_for(@pet) do |f| %> + + + + <% end %> + <% end %> + +
+ +<%= link_to 'Show', @pet %> <%= link_to 'Back', pets_path %> diff --git a/app/views/pets/index.html.erb b/app/views/pets/index.html.erb index e49229f..508f8bf 100644 --- a/app/views/pets/index.html.erb +++ b/app/views/pets/index.html.erb @@ -7,7 +7,8 @@ - + + @@ -15,9 +16,10 @@ <% @pets.each do |pet| %> - - + + + diff --git a/app/views/pets/show.html.erb b/app/views/pets/show.html.erb index be8ecbc..e29948d 100644 --- a/app/views/pets/show.html.erb +++ b/app/views/pets/show.html.erb @@ -2,12 +2,12 @@

Color: - <%= @pet.color %> + <%= @pet.color.hex_value %>

Shape: - <%= @pet.shape %> + <%= image_tag(@pet.shape.image)%>

diff --git a/app/views/shapes/index.html.erb b/app/views/shapes/index.html.erb index 7861499..8d82e3d 100644 --- a/app/views/shapes/index.html.erb +++ b/app/views/shapes/index.html.erb @@ -15,7 +15,7 @@ <% @shapes.each do |shape| %>

- + diff --git a/app/views/shapes/show.html.erb b/app/views/shapes/show.html.erb index 0fc6c39..d03b0c2 100644 --- a/app/views/shapes/show.html.erb +++ b/app/views/shapes/show.html.erb @@ -7,7 +7,7 @@

Image: - <%= @shape.image %> + <%= image_tag(@shape.image)%>

<%= link_to 'Edit', edit_shape_path(@shape) %> | diff --git a/config/routes.rb b/config/routes.rb index 20e003b..dcb5557 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ devise_for :users resources :campaigns - devise_scope :users do + devise_scope :user do get 'register', to: 'devise/registrations#new', as: :register get 'login', to: 'devise/sessions#new', as: :login end
Hex valueHex Value
<%= color.hex_value %> <%= link_to 'Show', color %> <%= link_to 'Edit', edit_color_path(color) %> <%= link_to 'Destroy', color, method: :delete, data: { confirm: 'Are you sure?' } %>
Color ShapeLast nameNameLucky Number
<%= pet.color %><%= pet.shape %><%= image_tag(pet.shape.image)%> <%= pet.full_name %><%= pet.lucky_number %> <%= link_to 'Show', pet %> <%= link_to 'Edit', edit_pet_path(pet) %> <%= link_to 'Destroy', pet, method: :delete, data: { confirm: 'Are you sure?' } %>
<%= shape.name %><%= shape.image %><%= image_tag(shape.image)%> <%= link_to 'Show', shape %> <%= link_to 'Edit', edit_shape_path(shape) %> <%= link_to 'Destroy', shape, method: :delete, data: { confirm: 'Are you sure?' } %>