Skip to content

Instantly share code, notes, and snippets.

@JRizzle88
JRizzle88 / main.rb
Last active July 8, 2016 22:31
A small Ruby program that returns the value of given position in a Fibonacci sequence.
# ask the user what position
puts "What position of a Fibonacci sequence would you like to see the value of? (Ex: position 6 = 8)"
# method for returning the value of a position in a Fibonacci sequence
def fibo_it(num)
num <= 1 ? num : fibo_it(num - 2) + fibo_it(num - 1)
end
# get the user input and convert to integer
pos = gets.chomp.to_i
@JRizzle88
JRizzle88 / email.rb
Last active August 29, 2015 13:56
undefined method `model_name' error pointing to line1 in footer_connect.html.erb for the form_for(@emails)
class Email < ActiveRecord::Base
validates_presence_of :first_name, :last_name, :email_address
validates_format_of :first_name, :last_name, :with => /^[A-Za-z0-9.&]*\z/
validates_format_of :email_address, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
validates_uniqueness_of :email_address
end
@JRizzle88
JRizzle88 / _prod_left_menu.html.erb
Last active January 1, 2016 13:29
uninitialized constant ActionView::CompiledTemplates::PROD_CAT_DISPLAY
<%= "<li" + (if url_category == category then " class='down-arrow'>" else ">" end) %>
<%= link_to PROD_CAT_DISPLAY[category], categories_path(:product_cat => category.downcase) %></li>
@JRizzle88
JRizzle88 / index.html.erb
Last active December 30, 2015 17:39
Couldn't find Studio without an ID , Trying to create new studio when button is clicked in the products view. The error is pointing to def set_studio @studio = Studio.find(params[:id])
### PRODUCTS VIEW ###
<%= button_to 'Customize', new_studio_path, method: :get, :class => 'button [tiny small large] middle pos-10-top' %>
@JRizzle88
JRizzle88 / index.html.erb
Last active December 30, 2015 17:29
studio No route matches [POST] "/studios/new" , trying to just create a new studio from a button_to with new_studio_path IN the products/index view. I have the Model empty
## PRODUCTS VIEW ##
<%= button_to 'Customize', new_studio_path, :class => 'button [tiny small large] middle pos-10-top' %>
@JRizzle88
JRizzle88 / index.html.erb
Created November 30, 2013 02:31
ERROR: relation "product_categories_products" does not exist LINE 1: DELETE FROM "product_categories_products" WHERE "product_cat...
<h3>Product Categories</h3>
<div class="large-4 columns">
<%= render 'form' %>
</div>
<div class="large-8 columns">
<table>
<thead>
<tr>
<th width="300">Name</th>
# views/admin/product_categories/_form.html.erb
<%= simple_form_for(@product_category) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :name %>
</div>
<div class="form-actions">
#/views/products/index.html.erb
<div class="hide-for-small panel">
<h3>Sidebar</h3>
<h5 class="subheader">Feature Product</h5>
<% Product.random do |product|%>
<%= image_tag(Product.image_url) %>
<h5><%= link_to Product.title, product %></h5>
<p><%= button_to 'Add to Cart', line_items_path(:product_id => product) %></p>
<% end %>