Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8539c13
Created animals#index and verified by rendering the browser
RanaSulaiman Mar 27, 2017
f143855
Created animal model and schema that has 4 clolumns name,species, age…
RanaSulaiman Mar 27, 2017
f488fd1
1-Updated #index in animals_controller and used Animal.all to retriev…
RanaSulaiman Mar 28, 2017
5d1ff53
Changed the layout of the index table to render as a table 'css/table'
RanaSulaiman Mar 28, 2017
48d4341
localhost/animals/1 now shows the details of one specific animal. Upd…
RanaSulaiman Mar 28, 2017
259266e
Animal's name now is a link redirect to the animal's page details
RanaSulaiman Mar 28, 2017
b5897d6
Created new migration to add new column 'image_link' and deleted exis…
RanaSulaiman Mar 28, 2017
2279a3d
Working on the edit/update action. Updated the routes.rb and the cont…
RanaSulaiman Mar 28, 2017
cec5fc8
Added partial form for edit. Now /animals/2/edit renders on the browser
RanaSulaiman Mar 28, 2017
7dbc8fb
Used edit form to fill out URL image for each animal.Saved when hit s…
RanaSulaiman Mar 28, 2017
ac7215e
Added image_tag to display the animal's image in each animal details …
RanaSulaiman Mar 28, 2017
6ebf6ad
Added edit button for each animal in the home/index page
RanaSulaiman Mar 28, 2017
ac6768a
Updated controller#action and routes to create new form #new and to s…
RanaSulaiman Mar 28, 2017
d99997e
Added new.html.erb using partial form
RanaSulaiman Mar 28, 2017
15a278c
Added a link on the home page to create a new animal
RanaSulaiman Mar 28, 2017
2c632c1
Added home link to the page of each animal. The animals webpage meets…
RanaSulaiman Mar 28, 2017
abc576c
Added background image and some styling
RanaSulaiman Mar 29, 2017
e60a432
Changed some styling
RanaSulaiman Mar 29, 2017
5751f38
Trying to chnage the home page to display the animal's image
RanaSulaiman Mar 29, 2017
630f660
Added two more animals to database
RanaSulaiman Mar 30, 2017
b780037
Changed the background image
RanaSulaiman Mar 30, 2017
85b23db
Changed some styling
RanaSulaiman Mar 30, 2017
9df31e8
Changed some text
RanaSulaiman Mar 31, 2017
84b6f38
Added default root route
RanaSulaiman Apr 1, 2017
ba11f85
Fixed some indentations
RanaSulaiman Apr 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore Byebug command history file.
.byebug_history
53 changes: 53 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
source 'https://rubygems.org'

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
174 changes: 174 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.2)
actionpack (= 5.0.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.2)
actionview (= 5.0.2)
activesupport (= 5.0.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.2)
activesupport (= 5.0.2)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.2)
activesupport (= 5.0.2)
globalid (>= 0.3.6)
activemodel (5.0.2)
activesupport (= 5.0.2)
activerecord (5.0.2)
activemodel (= 5.0.2)
activesupport (= 5.0.2)
arel (~> 7.0)
activesupport (5.0.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
builder (3.2.3)
byebug (9.0.6)
coffee-rails (4.2.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.2.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.7.0)
ffi (1.9.18)
globalid (0.3.7)
activesupport (>= 4.1.0)
i18n (0.8.1)
jbuilder (2.6.3)
activesupport (>= 3.0.0, < 5.2)
multi_json (~> 1.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
nio4r (2.0.0)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
puma (3.8.2)
rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.2)
actioncable (= 5.0.2)
actionmailer (= 5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
activemodel (= 5.0.2)
activerecord (= 5.0.2)
activesupport (= 5.0.2)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.2)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.2)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.2)
actionpack (= 5.0.2)
activesupport (= 5.0.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
sass (3.4.23)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
spring (2.0.1)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.1.10)
execjs (>= 0.3.0, < 3)
web-console (3.4.0)
actionview (>= 5.0)
activemodel (>= 5.0)
debug_inspector
railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)

PLATFORMS
ruby

DEPENDENCIES
byebug
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
jquery-rails
listen (~> 3.0.5)
puma (~> 3.0)
rails (~> 5.0.2)
sass-rails (~> 5.0)
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
turbolinks (~> 5)
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)

BUNDLED WITH
1.14.6
91 changes: 13 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,24 @@
# Rails Zoo
In this project, you will create a new rails application to track the animals in your Rails Zoo!
# README

You will practice the Rails basics in a new context. To keep the requirements manageable, this application will cover only the **CR** pieces of **CRUD**. This is an individual Stage 2 project.
This README would normally document whatever steps are necessary to get the
application up and running.

Each requirements section of this assignment has three sections: **think, create and verify**.
- Use the **think** section to look up and test your recall on these topics. Each answer is directly relevant to the steps you need to execute in the **create** section.
- The **create** section contains what you would see in a "normal" project's requirements.
- The **verify** section contains the steps to verify your work in the **create** section. This gives you a moment to double check your work before moving on to the next requirement.
Things you may want to cover:

* Ruby version

* System dependencies

## Setup
1. Fork and clone this project
2. Create a new rails application _within this folder_ using `rails new .`
* Configuration

## Primary Requirements
### Create Controller & Model
**Think**:
- What Rails CLI command do we use to generate a new controller? Are controllers supposed to be singular or plural?
- What Rails CLI command do we use to generate a new model? Are models supposed to be singular or plural? Where do we put the fields in the migration?
* Database creation

**Create**:
1. a rails controller with the name `animals`
1. a new model (migration) with the name `animal`
- each animal shall have a `name`, `species` and an `age` (add any other fields you want to track about the animals)
- i.e. Georgia is a Lion who is 4 years old
1. create the schema from the migration by running `rails db:migrate`
* Database initialization

**Verify**:
1. Check the `schema.rb` file and ensure all fields you expect are in the animals table
- if they are not, you may need to create another migration
1. Run the `rails console` from the command line and create a few new animals and save them to the database. These animals will be used in the next set of requirements
* How to run the test suite

### View All Animals
**Think**:
- Which route (including controller#action) do you use for viewing _all_ of a given resource?
- Which _model method_ do you use to retrieve _every item_ from the database?
* Services (job queues, cache servers, search engines, etc.)

**Create**:
1. the route
1. the controller action which will retrieve all animals from the database
1. the view containing HTML & ERB to see all animal data
* Deployment instructions

**Verify**:
1. http://localhost:3000/animals should show a list of all animals in the database that you added in the `rails console` from the previous section


### View One Animal
**Think**:
- Which route (including controller#action) do you use for viewing a _single_ resource?
- Which _model method_ do you use to retrieve a _single_ item from the database?

**Create**:
1. the route (including the param)
1. the controller action which will retrieve one specific animal from the database
1. the view containing HTML & ERB to see a single animal details
- you can use [lorem pixel](http://lorempixel.com) to get animal images if you'd like to include a random photo for each animal
1. add a link to the list of animals which will take you to each animals details page

**Verify**:
1. http://localhost:3000/animals will now include links for each animal's detail page
1. http://localhost:3000/animals/1 should show you the details of one specific animal (assuming you have an animal in the database with an ID of 1)

### Create an Animal
**Think**:
- Which **routes** (including controller#action) do you use for creating a new resource? What is the purpose of each route and how do they work together to complete the whole action?
- Which _model methods_ do you use to create and save a new item to the database?

**Create**:
1. the routes
1. a link on the home page to create a new animal
1. the controller action for the first route which renders the form
1. the view to render the form
1. the controller action for the second route which saves the form database
1. the special controller method for utilizing strong parameters

**Verify**:
1. http://localhost:3000/animals should contain a button to create a new animal
1. http://localhost:3000/animals/new should show the new animal form
1. submitting the new animal form should save an animal to the database and show the full list, including the new animal on http://localhost:3000/animals



## Optional
- Complete the edit/update action
- Complete the delete action
- Add an image field to the model for an Animal
- this field will store the location of an image on the internet and be used to display the image on the animal's show page
* ...
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'

Rails.application.load_tasks
3 changes: 3 additions & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
Empty file added app/assets/images/.keep
Empty file.
Binary file added app/assets/images/Sun-Rising.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/flamingo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/grass.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading