Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: marcusphillips/koalabear
base: 57aa3a3b13
...
head fork: marcusphillips/koalabear
compare: 97094456fc
Checking mergeability… Don't worry, you can still create the pull request.
  • 12 commits
  • 25 files changed
  • 0 commit comments
  • 1 contributor
View
BIN  app/assets/images/cafekoala.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/translucent.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  app/assets/javascripts/app.coffee.erb
@@ -0,0 +1,3 @@
+$ ->
+ $.vegas
+ src:'<%= asset_path('cafekoala.jpg') %>'
View
475 app/assets/javascripts/jquery.vegas.js
@@ -0,0 +1,475 @@
+// ----------------------------------------------------------------------------
+// Vegas - jQuery plugin
+// Add awesome fullscreen backgrounds to your webpages.
+// v 1.2
+// Dual licensed under the MIT and GPL licenses.
+// http://vegas.jaysalvat.com/
+// ----------------------------------------------------------------------------
+// Copyright (C) 2011 Jay Salvat
+// http://jaysalvat.com/
+// ----------------------------------------------------------------------------
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files ( the "Software" ), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// ----------------------------------------------------------------------------
+( function( $ ){
+ var $background = $( '<img />' ).addClass( 'vegas-background' ),
+ $overlay = $( '<div />' ).addClass( 'vegas-overlay' ),
+ $loading = $( '<div />' ).addClass( 'vegas-loading' ),
+ $current = $(),
+ paused = null,
+ backgrounds = [],
+ step = 0,
+ delay = 5000,
+ timer,
+ methods = {
+
+ // Init plugin
+ init : function( settings ) {
+
+ var options = {
+ src: getBackground(),
+ align: 'center',
+ valign: 'center',
+ fade: 0,
+ loading: true,
+ load: function() {},
+ complete: function() {}
+ }
+ $.extend( options, $.vegas.defaults.background, settings );
+
+ if ( options.loading ) {
+ loading();
+ }
+
+ var $new = $background.clone();
+ $new.css( {
+ 'position': 'fixed',
+ 'left': '0px',
+ 'top': '0px'
+ })
+ .imagesLoadedForVegas( function() {
+ if ( $new == $current ) {
+ return;
+ }
+
+ $( window ).bind( 'resize.vegas', function( e ) {
+ resize( $new, options );
+ });
+
+ if ( $current.is( 'img' ) ) {
+
+ $current.stop();
+
+ $new.hide()
+ .insertAfter( $current )
+ .fadeIn( options.fade, function() {
+ $('.vegas-background')
+ .not(this)
+ .remove();
+ $( 'body' ).trigger( 'vegascomplete', [ this, step - 1 ] );
+ options.complete.apply( $new, [ step - 1 ] );
+ });
+ } else {
+ $new.hide()
+ .prependTo( 'body' )
+ .fadeIn( options.fade, function() {
+ $( 'body' ).trigger( 'vegascomplete', [ this, step - 1 ] );
+ options.complete.apply( this, [ step - 1 ] );
+ });
+ }
+
+ $current = $new;
+
+ resize( $current, options );
+
+ if ( options.loading ) {
+ loaded();
+ }
+
+ $( 'body' ).trigger( 'vegasload', [ $current.get(0), step - 1 ] );
+ options.load.apply( $current.get(0), [ step - 1 ] );
+
+ if ( step ) {
+ $( 'body' ).trigger( 'vegaswalk', [ $current.get(0), step - 1 ] );
+ options.walk.apply( $current.get(0), [ step - 1 ] );
+ }
+ })
+ .attr( 'src', options.src );
+
+ return $.vegas;
+ },
+
+ // Destroy background and/or overlay
+ destroy: function( what ) {
+ if ( !what || what == 'background') {
+ $( '.vegas-background, .vegas-loading' ).remove();
+ $( window ).unbind( 'resize.vegas' );
+ $current = null;
+ }
+
+ if ( what == 'overlay') {
+ $( '.vegas-overlay' ).remove();
+ }
+
+ return $.vegas;
+ },
+
+ // Display the pattern overlay
+ overlay: function( settings ) {
+ var options = {
+ src: null,
+ opacity: null
+ };
+ $.extend( options, $.vegas.defaults.overlay, settings );
+
+ $overlay.remove();
+
+ $overlay
+ .css( {
+ 'margin': '0',
+ 'padding': '0',
+ 'position': 'fixed',
+ 'left': '0px',
+ 'top': '0px',
+ 'width': '100%',
+ 'height': '100%'
+ });
+
+ if ( options.src ) {
+ $overlay.css( 'backgroundImage', 'url(' + options.src + ')' );
+ }
+
+ if ( options.opacity ) {
+ $overlay.css( 'opacity', options.opacity );
+ }
+
+ $overlay.prependTo( 'body' );
+
+ return $.vegas;
+ },
+
+ // Start/restart slideshow
+ slideshow: function( settings, keepPause ) {
+ var options = {
+ step: step,
+ delay: delay,
+ preload: false,
+ backgrounds: backgrounds,
+ walk: function() {}
+ };
+
+ $.extend( options, $.vegas.defaults.slideshow, settings );
+
+ if ( options.backgrounds != backgrounds ) {
+ if ( !settings.step ) {
+ options.step = 0;
+ }
+
+ if ( options.preload ) {
+ $.vegas( 'preload', options.backgrounds );
+ }
+ }
+
+ backgrounds = options.backgrounds;
+ delay = options.delay;
+ step = options.step;
+
+ clearInterval( timer );
+
+ if ( !backgrounds.length ) {
+ return $.vegas;
+ }
+
+ var doSlideshow = function() {
+ if ( step < 0 ) {
+ step = backgrounds.length - 1;
+ }
+
+ if ( step >= backgrounds.length || !backgrounds[ step - 1 ] ) {
+ step = 0;
+ }
+
+ var settings = backgrounds[ step++ ];
+ settings.walk = options.walk;
+
+ if ( settings.fade > options.delay ) {
+ settings.fade = options.delay;
+ }
+
+ $.vegas( settings );
+ }
+ doSlideshow();
+
+ if ( !keepPause ) {
+ paused = false;
+
+ $( 'body' ).trigger( 'vegasstart', [ $current.get(0), step - 1 ] );
+ }
+
+ if ( !paused ) {
+ timer = setInterval( doSlideshow, options.delay );
+ }
+
+ return $.vegas;
+ },
+
+ // Jump to the next background in the current slideshow
+ next: function() {
+ var from = step;
+
+ if ( step ) {
+ $.vegas( 'slideshow', { step: step }, true );
+
+ $( 'body' ).trigger( 'vegasnext', [ $current.get(0), step - 1, from - 1 ] );
+ }
+
+ return $.vegas;
+ },
+
+ // Jump to the previous background in the current slideshow
+ previous: function() {
+ var from = step;
+
+ if ( step ) {
+ $.vegas( 'slideshow', { step: step - 2 }, true );
+
+ $( 'body' ).trigger( 'vegasprevious', [ $current.get(0), step - 1, from - 1 ] );
+ }
+
+ return $.vegas;
+ },
+
+ // Jump to a specific background in the current slideshow
+ jump: function( s ) {
+ var from = step;
+
+ if ( step ) {
+ $.vegas( 'slideshow', { step: s }, true );
+
+ $( 'body' ).trigger( 'vegasjump', [ $current.get(0), step - 1, from - 1 ] );
+ }
+
+ return $.vegas;
+ },
+
+ // Stop slideshow
+ stop: function() {
+ var from = step;
+ step = 0;
+ paused = null;
+ clearInterval( timer );
+
+ $( 'body' ).trigger( 'vegasstop', [ $current.get(0), from - 1 ] );
+
+ return $.vegas;
+ },
+
+ // Pause slideShow
+ pause: function() {
+ paused = true;
+ clearInterval( timer );
+
+ $( 'body' ).trigger( 'vegaspause', [ $current.get(0), step - 1 ] );
+
+ return $.vegas;
+ },
+
+ // Get some useful values or objects
+ get: function( what ) {
+ if ( what == null || what == 'background' ) {
+ return $current.get(0);
+ }
+
+ if ( what == 'overlay' ) {
+ return $overlay.get(0);
+ }
+
+ if ( what == 'step' ) {
+ return step - 1;
+ }
+
+ if ( what == 'paused' ) {
+ return paused;
+ }
+ },
+
+ // Preload an array of backgrounds
+ preload: function( backgrounds ) {
+ for( var i in backgrounds ) {
+ if ( backgrounds[ i ].src ) {
+ $('<img src="' + backgrounds[ i ].src + '">');
+ }
+ }
+
+ return $.vegas;
+ }
+ }
+
+ // Resize the background
+ function resize( $img, settings ) {
+ var options = {
+ align: 'center',
+ valign: 'center'
+ }
+ $.extend( options, settings );
+
+ var ww = $( window ).width(),
+ wh = $( window ).height(),
+ iw = $img.width(),
+ ih = $img.height(),
+ rw = wh / ww,
+ ri = ih / iw,
+ newWidth, newHeight,
+ newLeft, newTop,
+ properties;
+
+ if ( rw > ri ) {
+ newWidth = wh / ri;
+ newHeight = wh;
+ } else {
+ newWidth = ww;
+ newHeight = ww * ri;
+ }
+
+ properties = {
+ 'width': newWidth + 'px',
+ 'height': newHeight + 'px',
+ 'top': 'auto',
+ 'bottom': 'auto',
+ 'left': 'auto',
+ 'right': 'auto'
+ }
+
+ if ( !isNaN( parseInt( options.valign ) ) ) {
+ properties[ 'top' ] = ( 0 - ( newHeight - wh ) / 100 * parseInt( options.valign ) ) + 'px';
+ } else if ( options.valign == 'top' ) {
+ properties[ 'top' ] = 0;
+ } else if ( options.valign == 'bottom' ) {
+ properties[ 'bottom' ] = 0;
+ } else {
+ properties[ 'top' ] = ( wh - newHeight ) / 2;
+ }
+
+ if ( !isNaN( parseInt( options.align ) ) ) {
+ properties[ 'left' ] = ( 0 - ( newWidth - ww ) / 100 * parseInt( options.align ) ) + 'px';
+ } else if ( options.align == 'left' ) {
+ properties[ 'left' ] = 0;
+ } else if ( options.align == 'right' ) {
+ properties[ 'right' ] = 0;
+ } else {
+ properties[ 'left' ] = ( ww - newWidth ) / 2 ;
+ }
+
+ $img.css( properties );
+ }
+
+ // Display the loading indicator
+ function loading() {
+ $loading.prependTo( 'body' ).fadeIn();
+ }
+
+ // Hide the loading indicator
+ function loaded() {
+ $loading.fadeOut( 'fast', function() {
+ $( this ).remove();
+ });
+ }
+
+ // Get the background image from the body
+ function getBackground() {
+ if ( $( 'body' ).css( 'backgroundImage' ) ) {
+ return $( 'body' ).css( 'backgroundImage' ).replace( /url\("?(.*?)"?\)/i, '$1' );
+ }
+ }
+
+ // The plugin
+ $.vegas = function( method ) {
+ if ( methods[ method ] ) {
+ return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) );
+ } else if ( typeof method === 'object' || !method ) {
+ return methods.init.apply( this, arguments );
+ } else {
+ $.error( 'Method ' + method + ' does not exist' );
+ }
+ };
+
+ // Global parameters
+ $.vegas.defaults = {
+ background: {
+ // src: string
+ // align: string/int
+ // valign: string/int
+ // fade: int
+ // loading bool
+ // load: function
+ // complete: function
+ },
+ slideshow: {
+ // step: int
+ // delay: int
+ // backgrounds: array
+ // preload: bool
+ // walk: function
+ },
+ overlay: {
+ // src: string
+ // opacity: float
+ }
+ }
+
+ /*!
+ * jQuery imagesLoaded plugin v1.0.3
+ * http://github.com/desandro/imagesloaded
+ *
+ * MIT License. by Paul Irish et al.
+ */
+ $.fn.imagesLoadedForVegas = function( callback ) {
+ var $this = this,
+ $images = $this.find('img').add( $this.filter('img') ),
+ len = $images.length,
+ blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';
+
+ function triggerCallback() {
+ callback.call( $this, $images );
+ }
+
+ function imgLoaded() {
+ if ( --len <= 0 && this.src !== blank ){
+ setTimeout( triggerCallback );
+ $images.unbind( 'load error', imgLoaded );
+ }
+ }
+
+ if ( !len ) {
+ triggerCallback();
+ }
+
+ $images.bind( 'load error', imgLoaded ).each( function() {
+ // cached images don't fire load sometimes, so we reset src.
+ if (this.complete || this.complete === undefined){
+ var src = this.src;
+ // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
+ // data uri bypasses webkit log warning (thx doug jones)
+ this.src = blank;
+ this.src = src;
+ }
+ });
+
+ return $this;
+ };
+})( jQuery );
View
1  app/assets/stylesheets/app.css.scss
@@ -0,0 +1 @@
+.hero-unit.form-container{padding: 30px; margin-top: 30px; background: image-url("translucent.png"); color: #eee; }
View
24 app/assets/stylesheets/jquery.vegas.css
@@ -0,0 +1,24 @@
+.vegas-loading {
+ /* Loading Gif by http://preloaders.net/ */
+ -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px;
+ background:#000 url(image-url('loading.gif')) no-repeat center center;
+ background:rgba(0, 0, 0, 0.7) url(image-url('loading.gif')) no-repeat center center;
+ height:32px;
+ left:20px;
+ position:fixed;
+ top:20px;
+ width:32px;
+ z-index:0;
+}
+
+.vegas-overlay {
+ background:transparent url(overlays/01.png);
+ opacity:0.5;
+ z-index:-1;
+}
+
+.vegas-background {
+ image-rendering: optimizeQuality;
+ -ms-interpolation-mode: bicubic;
+ z-index:-2;
+}
View
3  app/assets/stylesheets/shares.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the shares controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
25 app/controllers/shares_controller.rb
@@ -0,0 +1,25 @@
+class SharesController < ApplicationController
+ def new
+ @share = Share.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @share }
+ end
+ end
+
+ def create
+ @share = Share.new(params[:share])
+
+ respond_to do |format|
+ if @share.save
+ u = User.find session[:user_id]
+ format.html { redirect_to edit_user_path(u), notice: 'Share was successfully created.' }
+ format.json { render json: @share, status: :created, location: @share }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @share.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+end
View
44 app/controllers/users_controller.rb
@@ -1,33 +1,43 @@
class UsersController < ApplicationController
- respond_to :json
+ def new
+ @user = User.new
- def index
- @users = User.all
- respond_with @users
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @user }
+ end
end
- def show
+ def edit
@user = User.find(params[:id])
- respond_with @user
end
def create
@user = User.new(params[:user])
- @user.save ?
- render(json: @user, status: :created, location: @user) :
- render(json: @user.errors, status: :unprocessable_entity)
+
+ respond_to do |format|
+ if @user.save
+ session[:user_id] = @user.id
+ format.html { redirect_to new_share_path, notice: 'User was successfully created.' }
+ format.json { render json: @user, status: :created, location: @user }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @user.errors, status: :unprocessable_entity }
+ end
+ end
end
def update
@user = User.find(params[:id])
- @user.update_attributes(params[:user]) ?
- head(:no_content) :
- render(json: @user.errors, status: :unprocessable_entity)
- end
- def destroy
- @user = User.find(params[:id])
- @user.destroy
- head :no_content
+ respond_to do |format|
+ if @user.update_attributes(params[:user])
+ format.html { redirect_to @user, notice: 'User was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @user.errors, status: :unprocessable_entity }
+ end
+ end
end
end
View
4 app/models/share.rb
@@ -0,0 +1,4 @@
+class Share < ActiveRecord::Base
+ belongs_to :user
+ attr_accessible :service, :user_id
+end
View
1  app/models/user.rb
@@ -1,3 +1,4 @@
class User < ActiveRecord::Base
+ has_many :shares
attr_accessible :birthday, :email, :facebook_uid, :level, :max_price, :name, :phone, :source, :twitter_uid, :why_english
end
View
3  app/views/application/home.html.erb
@@ -1,3 +0,0 @@
-<div class="well">
- hi!
-</div>
View
18 app/views/layouts/application.html.erb
@@ -3,12 +3,24 @@
<head>
<title>Koalabear</title>
<%= stylesheet_link_tag "application", :media => "all" %>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
-
-<%= yield %>
-
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="brand" href="#"> Project name </a>
+ </div>
+ </div>
+ </div>
+ <div class="container-fluid" id="content">
+ <div class="span12">
+ <div class="hero-unit form-container">
+ <%= yield %>
+ </div>
+ </div>
+ </div>
</body>
</html>
View
25 app/views/shares/_form.html.erb
@@ -0,0 +1,25 @@
+<%= form_for(@share) do |f| %>
+ <% if @share.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@share.errors.count, "error") %> prohibited this share from being saved:</h2>
+
+ <ul>
+ <% @share.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :user_id %><br />
+ <%= f.number_field :user_id %>
+ </div>
+ <div class="field">
+ <%= f.label :service %><br />
+ <%= f.text_field :service %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
View
5 app/views/shares/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New share</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', shares_path %>
View
57 app/views/users/_form.html.erb
@@ -1,57 +0,0 @@
-<%= form_for(@user) do |f| %>
- <% if @user.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
-
- <ul>
- <% @user.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <div class="field">
- <%= f.label :email %><br />
- <%= f.text_field :email %>
- </div>
- <div class="field">
- <%= f.label :phone %><br />
- <%= f.text_field :phone %>
- </div>
- <div class="field">
- <%= f.label :name %><br />
- <%= f.text_field :name %>
- </div>
- <div class="field">
- <%= f.label :facebook_uid %><br />
- <%= f.text_field :facebook_uid %>
- </div>
- <div class="field">
- <%= f.label :twitter_uid %><br />
- <%= f.text_field :twitter_uid %>
- </div>
- <div class="field">
- <%= f.label :birthday %><br />
- <%= f.date_select :birthday %>
- </div>
- <div class="field">
- <%= f.label :why_english %><br />
- <%= f.text_area :why_english %>
- </div>
- <div class="field">
- <%= f.label :source %><br />
- <%= f.text_area :source %>
- </div>
- <div class="field">
- <%= f.label :level %><br />
- <%= f.text_field :level %>
- </div>
- <div class="field">
- <%= f.label :max_price %><br />
- <%= f.text_field :max_price %>
- </div>
- <div class="actions">
- <%= f.submit %>
- </div>
-<% end %>
View
11 app/views/users/_form_errors.html.erb
@@ -0,0 +1,11 @@
+<% if @user.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
+
+ <ul>
+ <% @user.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+<% end %>
View
42 app/views/users/edit.html.erb
@@ -1,6 +1,46 @@
<h1>Editing user</h1>
-<%= render 'form' %>
+<%= form_for(@user) do |f| %>
+ <%= render 'form_errors' %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :facebook_uid %><br />
+ <%= f.text_field :facebook_uid %>
+ </div>
+ <div class="field">
+ <%= f.label :twitter_uid %><br />
+ <%= f.text_field :twitter_uid %>
+ </div>
+ <div class="field">
+ <%= f.label :birthday %><br />
+ <%= f.date_select :birthday %>
+ </div>
+ <div class="field">
+ <%= f.label :why_english %><br />
+ <%= f.text_area :why_english %>
+ </div>
+ <div class="field">
+ <%= f.label :source %><br />
+ <%= f.text_area :source %>
+ </div>
+ <div class="field">
+ <%= f.label :level %><br />
+ <%= f.text_field :level %>
+ </div>
+ <div class="field">
+ <%= f.label :max_price %><br />
+ <%= f.text_field :max_price %>
+ </div>
+
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
+
<%= link_to 'Show', @user %> |
<%= link_to 'Back', users_path %>
View
41 app/views/users/index.html.erb
@@ -1,41 +0,0 @@
-<h1>Listing users</h1>
-
-<table>
- <tr>
- <th>Email</th>
- <th>Phone</th>
- <th>Name</th>
- <th>Facebook uid</th>
- <th>Twitter uid</th>
- <th>Birthday</th>
- <th>Why english</th>
- <th>Source</th>
- <th>Level</th>
- <th>Max price</th>
- <th></th>
- <th></th>
- <th></th>
- </tr>
-
-<% @users.each do |user| %>
- <tr>
- <td><%= user.email %></td>
- <td><%= user.phone %></td>
- <td><%= user.name %></td>
- <td><%= user.facebook_uid %></td>
- <td><%= user.twitter_uid %></td>
- <td><%= user.birthday %></td>
- <td><%= user.why_english %></td>
- <td><%= user.source %></td>
- <td><%= user.level %></td>
- <td><%= user.max_price %></td>
- <td><%= link_to 'Show', user %></td>
- <td><%= link_to 'Edit', edit_user_path(user) %></td>
- <td><%= link_to 'Destroy', user, confirm: 'Are you sure?', method: :delete %></td>
- </tr>
-<% end %>
-</table>
-
-<br />
-
-<%= link_to 'New User', new_user_path %>
View
16 app/views/users/new.html.erb
@@ -1,5 +1,19 @@
<h1>New user</h1>
-<%= render 'form' %>
+<%= form_for(@user) do |f| %>
+ <%= render 'form_errors' %>
+
+ <div class="field">
+ <%= f.label :email %><br />
+ <%= f.text_field :email %>
+ </div>
+ <div class="field">
+ <%= f.label :phone %><br />
+ <%= f.text_field :phone %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
<%= link_to 'Back', users_path %>
View
55 app/views/users/show.html.erb
@@ -1,55 +0,0 @@
-<p id="notice"><%= notice %></p>
-
-<p>
- <b>Email:</b>
- <%= @user.email %>
-</p>
-
-<p>
- <b>Phone:</b>
- <%= @user.phone %>
-</p>
-
-<p>
- <b>Name:</b>
- <%= @user.name %>
-</p>
-
-<p>
- <b>Facebook uid:</b>
- <%= @user.facebook_uid %>
-</p>
-
-<p>
- <b>Twitter uid:</b>
- <%= @user.twitter_uid %>
-</p>
-
-<p>
- <b>Birthday:</b>
- <%= @user.birthday %>
-</p>
-
-<p>
- <b>Why english:</b>
- <%= @user.why_english %>
-</p>
-
-<p>
- <b>Source:</b>
- <%= @user.source %>
-</p>
-
-<p>
- <b>Level:</b>
- <%= @user.level %>
-</p>
-
-<p>
- <b>Max price:</b>
- <%= @user.max_price %>
-</p>
-
-
-<%= link_to 'Edit', edit_user_path(@user) %> |
-<%= link_to 'Back', users_path %>
View
4 config/routes.rb
@@ -1,4 +1,6 @@
Koalabear::Application.routes.draw do
+ resources :shares
+
resources :users
- root :to => 'application#home'
+ root :to => 'users#new'
end
View
10 db/migrate/20120408204131_create_shares.rb
@@ -0,0 +1,10 @@
+class CreateShares < ActiveRecord::Migration
+ def change
+ create_table :shares do |t|
+ t.integer :user_id
+ t.string :service
+
+ t.timestamps
+ end
+ end
+end
View
9 db/schema.rb
@@ -11,7 +11,14 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120407234132) do
+ActiveRecord::Schema.define(:version => 20120408204131) do
+
+ create_table "shares", :force => true do |t|
+ t.integer "user_id"
+ t.string "service"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
create_table "users", :force => true do |t|
t.string "email"

No commit comments for this range

Something went wrong with that request. Please try again.