Skip to content

Commit

Permalink
destination_add completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Niroj Shrestha committed Dec 6, 2011
1 parent 3eeee01 commit 1bc89fd
Show file tree
Hide file tree
Showing 40 changed files with 845 additions and 252 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--colour
16 changes: 14 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ gem 'rails', '3.1.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'sqlite3'
gem 'devise'

gem 'json'

Expand All @@ -17,7 +18,18 @@ group :assets do
gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'jquery-rails'

group :test, :development do
gem 'rspec-rails'
end

group :test do
gem 'factory_girl_rails'
gem 'launchy'
gem 'capybara'
gem 'database_cleaner'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
Expand Down
62 changes: 59 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,57 @@ GEM
activesupport (= 3.1.3)
activesupport (3.1.3)
multi_json (~> 1.0)
addressable (2.2.6)
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.2.3)
ffi (~> 1.0.6)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.3)
database_cleaner (0.7.0)
devise (1.5.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
warden (~> 1.1)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.2.11)
multi_json (~> 1.0)
factory_girl (2.3.2)
activesupport
factory_girl_rails (1.4.0)
factory_girl (~> 2.3.0)
railties (>= 3.0.0)
ffi (1.0.11)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.3)
launchy (2.0.5)
addressable (~> 2.2.6)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
nokogiri (1.5.0)
orm_adapter (0.0.5)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
Expand Down Expand Up @@ -81,12 +108,31 @@ GEM
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
rspec (2.7.0)
rspec-core (~> 2.7.0)
rspec-expectations (~> 2.7.0)
rspec-mocks (~> 2.7.0)
rspec-core (2.7.1)
rspec-expectations (2.7.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.7.0)
rspec-rails (2.7.0)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.7.0)
rubyzip (0.9.5)
sass (3.1.11)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
selenium-webdriver (2.14.0)
childprocess (>= 0.2.1)
ffi (~> 1.0.9)
multi_json (~> 1.0.4)
rubyzip
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
Expand All @@ -101,15 +147,25 @@ GEM
uglifier (1.1.0)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
warden (1.1.0)
rack (>= 1.0)
xpath (0.1.4)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara
coffee-rails (~> 3.1.1)
jquery-rails ()
json ()
database_cleaner
devise
factory_girl_rails
jquery-rails
json
launchy
rails (= 3.1.3)
rspec-rails
sass-rails (~> 3.1.5)
sqlite3 ()
sqlite3
uglifier (>= 1.0.3)
3 changes: 3 additions & 0 deletions app/assets/javascripts/destinations.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/home.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/destinations.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the destinations controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/home.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
56 changes: 56 additions & 0 deletions app/assets/stylesheets/scaffolds.css.scss
Original file line number Diff line number Diff line change
@@ -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; } }
85 changes: 85 additions & 0 deletions app/controllers/destinations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
class DestinationsController < ApplicationController
# GET /destinations
# GET /destinations.json
before_filter :authenticate_user!

def index
@destinations = Destination.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @destinations }
end
end

# GET /destinations/1
# GET /destinations/1.json
def show
@destination = Destination.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @destination }
end
end

# GET /destinations/new
# GET /destinations/new.json
def new
@destination = Destination.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @destination }
end
end

# GET /destinations/1/edit
def edit
@destination = Destination.find(params[:id])
end

# POST /destinations
# POST /destinations.json
def create
@destination = Destination.new(params[:destination])

respond_to do |format|
if @destination.save
format.html { redirect_to @destination, notice: 'Destination was successfully created.' }
format.json { render json: @destination, status: :created, location: @destination }
else
format.html { render action: "new" }
format.json { render json: @destination.errors, status: :unprocessable_entity }
end
end
end

# PUT /destinations/1
# PUT /destinations/1.json
def update
@destination = Destination.find(params[:id])

respond_to do |format|
if @destination.update_attributes(params[:destination])
format.html { redirect_to @destination, notice: 'Destination was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @destination.errors, status: :unprocessable_entity }
end
end
end

# DELETE /destinations/1
# DELETE /destinations/1.json
def destroy
@destination = Destination.find(params[:id])
@destination.destroy

respond_to do |format|
format.html { redirect_to destinations_url }
format.json { head :ok }
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class HomeController < ApplicationController

before_filter :authenticate_user!

def show
end

end
2 changes: 2 additions & 0 deletions app/helpers/destinations_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module DestinationsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HomeHelper
end
5 changes: 5 additions & 0 deletions app/models/destination.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Destination < ActiveRecord::Base



end
9 changes: 9 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
end
25 changes: 25 additions & 0 deletions app/views/destinations/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<%= form_for(@destination) do |f| %>
<% if @destination.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@destination.errors.count, "error") %> prohibited this destination from being saved:</h2>

<ul>
<% @destination.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :place %><br />
<%= f.text_field :place %>
</div>
<div class="field">
<%= f.label :description %><br />
<%= f.text_area :description %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/destinations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Editing destination</h1>

<%= render 'form' %>
<%= link_to 'Show', @destination %> |
<%= link_to 'Back', destinations_path %>
25 changes: 25 additions & 0 deletions app/views/destinations/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<h1>Listing destinations</h1>

<table>
<tr>
<th>Place</th>
<th>Description</th>
<th></th>
<th></th>
<th></th>
</tr>

<% @destinations.each do |destination| %>
<tr>
<td><%= destination.place %></td>
<td><%= destination.description %></td>
<td><%= link_to 'Show', destination %></td>
<td><%= link_to 'Edit', edit_destination_path(destination) %></td>
<td><%= link_to 'Destroy', destination, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Destination', new_destination_path %>
Loading

0 comments on commit 1bc89fd

Please sign in to comment.