Skip to content

Instantly share code, notes, and snippets.

View jaake's full-sized avatar

Jacob Margason jaake

View GitHub Profile
@jaake
jaake / gist:186d55b13d1ed4bb549b
Created October 17, 2014 16:39
update problem
VIEW:
<% @foods.each do |panel| %>
<%= form_for panel do |f| %>
<div class='menu_edit'>
<div class="field">
<h2><%= f.text_field :title %></h2>
</div>
<div class="field">
<h3><%= f.text_field :item01 %></h3>
@jaake
jaake / gist:fc7cefb58808327e9c30
Created October 17, 2014 15:36
Understanding ActiveRecord.update
class FoodPanelsController < ApplicationController
before_filter :authorize, only: [:update]
def update
panel = FoodPanel.find(params[:id])
if panel.update(food_params)
redirect_to root_url
flash[:notice] = "Menu has been updated."
else
@photos = []
posts['data'].each do |photo|
caption = ""
caption = photo['caption']['text'] unless photo['caption'] == nil
url = photo['images']['standard_resolution']['url']
@photos.append(url, caption)
end
@jaake
jaake / gist:c5b7ac69fcfc242e4386
Created October 15, 2014 17:34
weird no method error
Started GET "/news" for 127.0.0.1 at 2014-10-15 12:31:14 -0500
Processing by HomeController#news as HTML
Rendered home/news.html.erb within layouts/application (1.5ms)
Completed 500 Internal Server Error in 278ms
ActionView::Template::Error (undefined method `[]' for nil:NilClass):
5: <% @photos.each do |photo| %>
6: <div class="instagram_image">
7: <div>
8: <span><%= photo['caption']['text'] %></span>
@jaake
jaake / gist:97c327f377cf4f0f89fc
Created October 12, 2014 23:16
Rails fails to pass in variables from controller:
class HomeController < ApplicationController
end
def index
end
def menu
@drinks = DrinkPanel.all
@foods = FoodPanel.all
end
@jaake
jaake / gist:ca73097a97f6ed8553c1
Created October 12, 2014 23:14
Rails fails to pass in variables from controller:
Started GET "/assets/home.css?body=1" for 127.0.0.1 at 2014-10-12 18:12:58 -0500
ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-10-12 18:12:58 -0500
Started GET "/assets/foundation/foundation.abide.js?body=1" for 127.0.0.1 at 2014-10-12 18:12:58 -0500