Skip to content

Instantly share code, notes, and snippets.

View JonasNielsen's full-sized avatar

Jonas Bylov JonasNielsen

View GitHub Profile
class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Successfully logged in."
redirect_to root_url
puts 'What\'s on your mind, son?'
question = gets.chomp
while question != question.upcase
puts 'WHAT?! SPEAK UP SON!'
question = gets.chomp
if question == question.upcase
millenium = 1930
year = millenium + rand(20)
puts 'NO, NOT SINCE '+ year.to_s + '!'
end
<% form_for @person, :url => { :action => "update" } do |person_form| %>
...
<% @person.projects.each do |project| %>
<% if project.active? %>
<% person_form.fields_for :projects, project do |project_fields| %>
Name: <%= project_fields.text_field :name %>
<% end %>
<% end %>
<% end %>
<% end %>
page.make_topics_sortable
# RETURNS ERROR:
# ActionView::TemplateError (stack level too deep)
# The sortable_element function is somehow the problem
# ERROR RETURNED ---------
ActionView::TemplateError (ActionView::Helpers::JavaScriptProxy#to_str should return String) on line #7 of app/views/topics/create.rjs:
4: page.replace_html :notice, flash[:notice]
5: flash.discard
6:
7: page.create_topics_sortable()
app/helpers/topics_helper.rb:7:in `create_topics_sortable'
app/views/topics/create.rjs:7:in `_run_rjs_app47views47topics47create46rjs'
app/views/topics/create.rjs:1:in `_run_rjs_app47views47topics47create46rjs'
- remote_form_for :topic, :url => topics_path(:topic), :html => {:id => 'topic_form'} do |f|
= f.hidden_field :slideshow_id, :value => slideshow_id
= f.label :title
= f.text_field :title
%br/
= f.submit 'Add Topic'
%h1 About
%p Here are some text about the business!
- content_for :client_authorization do
= render :partial => 'shared/client_authorization'
- content_for :admin_menu do
= render :partial => 'shared/admin_menu'
Processing PeopleController#new (for 127.0.0.1 at 2010-02-02 14:22:49) [GET]
Enterprise Load (0.4ms) SELECT * FROM "enterprises" LIMIT 1
Branch Load (0.4ms) SELECT * FROM "branches" WHERE ("branches".enterprise_id = 1) LIMIT 1
Person Load (0.1ms) SELECT * FROM "people" WHERE ("people".branch_id = 3) LIMIT 1
CREATE TABLE "branches" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "address" varchar(255), "city" varchar(255), "zip_code" integer, "created_at" datetime, "updated_at" datetime, "enterprise_id" integer);
CREATE TABLE "enterprises" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime);
CREATE TABLE "people" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255), "last_name" varchar(255), "sex" varchar(255), "age" integer, "email" varchar(255), "created_at" datetime, "updated_at" datetime, "branch_id" integer);
CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
class Enterprise < ActiveRecord::Base
has_many :branches
has_many :people, :through => :branches
end
class Branch < ActiveRecord::Base
has_many :people
belongs_to :enterprise
end