Skip to content
Browse files

hack

  • Loading branch information...
1 parent 46de674 commit f6488f68721deed93641f0facfad5e52ae3b7685 @danishkhan committed
View
2 Gemfile
@@ -5,7 +5,7 @@ gem 'rails', '3.1.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'sqlite3'
+gem 'mysql2'
gem 'json'
View
4 Gemfile.lock
@@ -53,6 +53,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
+ mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
@@ -105,7 +106,6 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -125,8 +125,8 @@ DEPENDENCIES
coffee-rails (~> 3.1.1)
jquery-rails
json
+ mysql2
rails (= 3.1.3)
resque
sass-rails (~> 3.1.5)
- sqlite3
uglifier (>= 1.0.3)
View
3 app/assets/javascripts/ates.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
View
3 app/assets/stylesheets/ates.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the ates controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
56 app/assets/stylesheets/scaffolds.css.scss
@@ -0,0 +1,56 @@
+body {
+ background-color: #fff;
+ color: #333;
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px; }
+
+p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px; }
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px; }
+
+a {
+ color: #000;
+ &:visited {
+ color: #666; }
+ &:hover {
+ color: #fff;
+ background-color: #000; } }
+
+div {
+ &.field, &.actions {
+ margin-bottom: 10px; } }
+
+#notice {
+ color: green; }
+
+.field_with_errors {
+ padding: 2px;
+ background-color: red;
+ display: table; }
+
+#error_explanation {
+ width: 450px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 0;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ margin-bottom: 0px;
+ background-color: #c00;
+ color: #fff; }
+ ul li {
+ font-size: 12px;
+ list-style: square; } }
View
83 app/controllers/ates_controller.rb
@@ -0,0 +1,83 @@
+class AtesController < ApplicationController
+ # GET /ates
+ # GET /ates.json
+ def index
+ @ates = Ate.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render :json => @ates }
+ end
+ end
+
+ # GET /ates/1
+ # GET /ates/1.json
+ def show
+ @ate = Ate.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render :json => @ate }
+ end
+ end
+
+ # GET /ates/new
+ # GET /ates/new.json
+ def new
+ @ate = Ate.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render :json => @ate }
+ end
+ end
+
+ # GET /ates/1/edit
+ def edit
+ @ate = Ate.find(params[:id])
+ end
+
+ # POST /ates
+ # POST /ates.json
+ def create
+ @ate = Ate.new(params[:ate])
+
+ respond_to do |format|
+ if @ate.save
+ format.html { redirect_to @ate, :notice => 'Ate was successfully created.' }
+ format.json { render :json => @ate, :status => :created, :location => @ate }
+ else
+ format.html { render :action => "new" }
+ format.json { render :json => @ate.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /ates/1
+ # PUT /ates/1.json
+ def update
+ @ate = Ate.find(params[:id])
+
+ respond_to do |format|
+ if @ate.update_attributes(params[:ate])
+ format.html { redirect_to @ate, :notice => 'Ate was successfully updated.' }
+ format.json { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.json { render :json => @ate.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /ates/1
+ # DELETE /ates/1.json
+ def destroy
+ @ate = Ate.find(params[:id])
+ @ate.destroy
+
+ respond_to do |format|
+ format.html { redirect_to ates_url }
+ format.json { head :ok }
+ end
+ end
+end
View
2 app/helpers/ates_helper.rb
@@ -0,0 +1,2 @@
+module AtesHelper
+end
View
2 app/models/ate.rb
@@ -0,0 +1,2 @@
+class Ate < ActiveRecord::Base
+end
View
21 app/views/ates/_form.html.erb
@@ -0,0 +1,21 @@
+<%= form_for(@ate) do |f| %>
+ <% if @ate.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@ate.errors.count, "error") %> prohibited this ate from being saved:</h2>
+
+ <ul>
+ <% @ate.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :food %><br />
+ <%= f.text_field :food %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
View
6 app/views/ates/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing ate</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @ate %> |
+<%= link_to 'Back', ates_path %>
View
23 app/views/ates/index.html.erb
@@ -0,0 +1,23 @@
+<h1>Listing ates</h1>
+
+<table>
+ <tr>
+ <th>Food</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @ates.each do |ate| %>
+ <tr>
+ <td><%= ate.food %></td>
+ <td><%= link_to 'Show', ate %></td>
+ <td><%= link_to 'Edit', edit_ate_path(ate) %></td>
+ <td><%= link_to 'Destroy', ate, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Ate', new_ate_path %>
View
5 app/views/ates/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New ate</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', ates_path %>
View
10 app/views/ates/show.html.erb
@@ -0,0 +1,10 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Food:</b>
+ <%= @ate.food %>
+</p>
+
+
+<%= link_to 'Edit', edit_ate_path(@ate) %> |
+<%= link_to 'Back', ates_path %>
View
8 config/database.yml
@@ -4,8 +4,8 @@
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
- adapter: sqlite3
- database: db/development.sqlite3
+ adapter: mysql2
+ database: resque_demo
pool: 5
timeout: 5000
@@ -19,7 +19,7 @@ test:
timeout: 5000
production:
- adapter: sqlite3
- database: db/production.sqlite3
+ adapter: mysql2
+ database: resque_demo
pool: 5
timeout: 5000
View
2 config/routes.rb
@@ -1,4 +1,6 @@
ResqueDemo::Application.routes.draw do
+ resources :ates
+
match 'eat/:food' => 'eat#food'
# The priority is based upon order of creation:
View
9 db/migrate/20111215003921_create_ates.rb
@@ -0,0 +1,9 @@
+class CreateAtes < ActiveRecord::Migration
+ def change
+ create_table :ates do |t|
+ t.string :food
+
+ t.timestamps
+ end
+ end
+end
View
21 db/schema.rb
@@ -0,0 +1,21 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20111215003921) do
+
+ create_table "ates", :force => true do |t|
+ t.string "food"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
View
7 test/fixtures/ates.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ food: MyString
+
+two:
+ food: MyString
View
49 test/functional/ates_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class AtesControllerTest < ActionController::TestCase
+ setup do
+ @ate = ates(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:ates)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create ate" do
+ assert_difference('Ate.count') do
+ post :create, :ate => @ate.attributes
+ end
+
+ assert_redirected_to ate_path(assigns(:ate))
+ end
+
+ test "should show ate" do
+ get :show, :id => @ate.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => @ate.to_param
+ assert_response :success
+ end
+
+ test "should update ate" do
+ put :update, :id => @ate.to_param, :ate => @ate.attributes
+ assert_redirected_to ate_path(assigns(:ate))
+ end
+
+ test "should destroy ate" do
+ assert_difference('Ate.count', -1) do
+ delete :destroy, :id => @ate.to_param
+ end
+
+ assert_redirected_to ates_path
+ end
+end
View
7 test/unit/ate_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AteTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
View
4 test/unit/helpers/ates_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class AtesHelperTest < ActionView::TestCase
+end

0 comments on commit f6488f6

Please sign in to comment.
Something went wrong with that request. Please try again.