Skip to content

Instantly share code, notes, and snippets.

@andrewhl
Created March 2, 2012 06:49
Show Gist options
  • Save andrewhl/1956320 to your computer and use it in GitHub Desktop.
Save andrewhl/1956320 to your computer and use it in GitHub Desktop.
<div class="field">
<%= f.label :program_name %><br />
<%= f.text_field :program_name %>
</div>
<div class="field">
<%= f.label :day %><br />
<%= f.text_field :day %>
</div>
<div class="field">
<%= f.label :price %><br />
<%= f.text_field :price %>
</div>
<div class="field">
<%= f.label :status %><br />
<%= f.text_field :status %>
</div>
<div class="field">
<%= f.label :dates %><br />
<%= f.text_field :dates %>
</div>
<div class="field">
<%= f.label :max_registrants %><br />
<%= f.text_field :max_registrants %>
</div>
# == Schema Information
#
# Table name: after_school_programs
#
# id :integer not null, primary key
# day :string(255)
# program_name :string(255)
# price :string(255)
# status :string(255)
# dates :string(255)
# max_registrants :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class AfterSchoolProgram < ActiveRecord::Base
attr_accessible :day,
:program_name,
:price,
:status,
:dates,
:max_registrants
end
class AfterSchoolProgramsController < ApplicationController
before_filter :admin_user
def new
@program = AfterSchoolProgram.new
end
def show
# @program = AfterSchoolProgram.find(params[:id])
end
def destroy
end
def edit
end
def index
@programs = AfterSchoolProgram.all
end
def create
@program = AfterSchoolProgram.new(params[:program])
puts "PARAMS before SAVE: #{params[:program].inspect}"
if @program.save
puts "PARAMS after SAVE: #{params[:program]}"
flash[:success] = "Your program has been created!"
redirect_to after_school_programs_path
else
render 'new'
end
end
end
Started POST "/after_school_programs" for 127.0.0.1 at 2012-03-02 01:49:01 -0500
Processing by AfterSchoolProgramsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"zp1MrItSNfZ2CKAOerxB4iBOdxU7CjBMVMskuV9VAbM=", "after_school_program"=>{"program_name"=>"test", "day"=>"test", "price"=>"test", "status"=>"test", "dates"=>"test", "max_registrants"=>"test"}, "commit"=>"Create program"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = 'i64J_AN1JzU1DtIhzxK3bQ' LIMIT 1
(0.0ms) begin transaction
SQL (69.7ms) INSERT INTO "after_school_programs" ("created_at", "dates", "day", "max_registrants", "price", "program_name", "status", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["created_at", Fri, 02 Mar 2012 06:49:01 UTC +00:00], ["dates", nil], ["day", nil], ["max_registrants", nil], ["price", nil], ["program_name", nil], ["status", nil], ["updated_at", Fri, 02 Mar 2012 06:49:01 UTC +00:00]]
(18.3ms) commit transaction
Redirected to http://localhost:3000/after_school_programs
Completed 302 Found in 91ms (ActiveRecord: 88.2ms)
<% provide :title, 'After School Programs Create Form' %>
<h2>Create programs here</h2>
<%= form_for(@program) do |f| %>
<%= render 'fields', f: f %>
<div class="actions">
<%= f.submit "Create program" %>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment