This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.hangman { | |
margin: 0 auto; | |
border: 1px solid black; | |
} | |
.hangman line { | |
stroke: black; | |
stroke-width: 4; | |
} | |
.hangman.dead line, | |
.hangman.dead circle { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place all the behaviors and hooks related to the matching controller here. | |
// All this logic will automatically be available in application.js. | |
function createWishlist(url, data) { | |
$.post(url, data, "json") | |
// on success create a new instance of our model object | |
.done(json => { | |
let myWishList = new Wishlist(json); | |
myWishList.updateHTML(); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Create a new wishlist</h1> | |
<!-- Form for creating a new Wishlist --> | |
<%= form_for([user, wishlist]) do |f|%> | |
<p> | |
<%= f.label :name %> | |
<%= f.text_field :name %><br> | |
<%= f.label :budget %> | |
<%= f.number_field :budget, value: number_to_currency(f.object.budget.to_f, delimiter: '', unit: ''), step: :any %><br> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Wishlist square --> | |
<div class="wishlist-info"> | |
<h1>Wishlist: <%= @wishlist.name%></h1> | |
<p>Created on: <%= @wishlist.date_created%></p> | |
<p>Budget: <%= number_to_currency(@wishlist.budget)%></p> | |
<p>Notes: <%= @wishlist.notes%></p> | |
<% if display_edit_delete_link %> | |
<%= link_to("Edit wishlist", edit_user_wishlist_path(@user, @wishlist)) %><br><br> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Button to show Next Product using AJAX GET request--> | |
<button class="js-next" data-id="<%= @product.id %>">Next product</button> | |
<br> | |
<!-- Product square --> | |
<div class="product-square"> | |
<h1 class="name"><%= @product.name%></h1> | |
<p class="category">Category: <%= @product.category.name%></p> | |
<p class="price">Price: <%= "#{number_to_currency(@product.price)}" %></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
post '/wishlists/:id/toggle_product' => 'wishlists#toggle_product', as: :toggle_wishlist_product | |
resources :users do | |
resources :wishlists | |
end | |
resources :sessions | |
resources :products do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
require 'pry' | |
class Scraper | |
def get_page(url_str) | |
html = open(url_str) | |
doc = Nokogiri::HTML(html) | |
doc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product < ActiveRecord::Base | |
belongs_to :wishlist | |
belongs_to :category | |
# Validations | |
validates :name, :price, :url, :image_link, presence: true | |
validates :url, uniqueness: true | |
validates :name, length: {minimum: 2} | |
#Scope methods |