diff --git a/Gemfile b/Gemfile index 2b6bd2978..2d412a150 100644 --- a/Gemfile +++ b/Gemfile @@ -1,27 +1,30 @@ source 'http://rubygems.org' -gem 'rails', '3.1' +gem 'rails', '3.1.0' -# To bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' -gem 'sqlite3', '~> 1.3.3' -gem 'haml' -gem 'ruby-tmdb' -gem 'rake', '0.8.7' - -group :test, :development do - gem 'capybara' - gem 'cucumber-rails' - gem 'cucumber' - gem 'rspec-rails' - gem 'rspec' - gem 'ruby-debug19' - gem 'rcov' +gem 'sqlite3' + + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', " ~> 3.1.0" + gem 'coffee-rails', "~> 3.1.0" + gem 'uglifier' end -# Bundle the extra gems: -# gem 'bj' -# gem 'nokogiri' -# gem 'sqlite3-ruby', :require => 'sqlite3' -# gem 'aws-s3', :require => 'aws/s3' +gem 'jquery-rails' + +# Use unicorn as the web server +# gem 'unicorn' + +# Deploy with Capistrano +# gem 'capistrano' + +# To use debugger +gem 'ruby-debug19', :require => 'ruby-debug' +gem 'haml' +gem 'railroady' diff --git a/Gemfile.lock b/Gemfile.lock index 6bd388f81..c5ee6a19d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,45 +30,28 @@ GEM activesupport (= 3.1.0) activesupport (3.1.0) multi_json (~> 1.0) -<<<<<<< HEAD - addressable (2.2.6) -======= archive-tar-minitar (0.5.2) ->>>>>>> e60314f... Updated gems to correct versions; updated form partial (at least one of them) to use new form_for syntax, which requires <%= and not <% on form_for to generate output; fixed syntax in migration since Time.parse and Date.parse take month/day args in opposite order in ruby 1.9 arel (2.2.1) bcrypt-ruby (3.0.1) builder (3.0.0) - capybara (1.1.1) - 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.2) - 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) columnize (0.3.4) - cucumber (1.1.0) - builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.5.0) - json (>= 1.4.6) - term-ansicolor (>= 1.0.6) - cucumber-rails (1.1.1) - capybara (>= 1.1.1) - cucumber (>= 1.1.0) - nokogiri (>= 1.5.0) - deepopenstruct (0.1.2) - diff-lcs (1.1.3) erubis (2.7.0) - ffi (1.0.9) - gherkin (2.5.4) - json (>= 1.4.6) + execjs (1.2.9) + multi_json (~> 1.0) haml (3.1.3) hike (1.2.1) i18n (0.6.0) + jquery-rails (1.0.18) + railties (~> 3.0) + thor (~> 0.14) json (1.6.1) - json_pure (1.6.1) linecache19 (0.5.12) ruby_core_source (>= 0.1.4) mail (2.3.0) @@ -77,8 +60,7 @@ GEM treetop (~> 1.4.8) mime-types (1.17.2) multi_json (1.0.3) - nokogiri (1.5.0) - polyglot (0.3.2) + polyglot (0.3.3) rack (1.3.5) rack-cache (1.0.3) rack (>= 0.4) @@ -88,6 +70,7 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) + railroady (1.0.2) rails (3.1.0) actionmailer (= 3.1.0) actionpack (= 3.1.0) @@ -103,40 +86,9 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) -<<<<<<< HEAD - rake (0.9.2) - rbx-require-relative (0.0.5) - rcov (0.9.9) - rdoc (3.9.4) -======= - rake (0.8.7) + rake (0.9.2.2) rdoc (3.11) json (~> 1.4) ->>>>>>> e60314f... Updated gems to correct versions; updated form partial (at least one of them) to use new form_for syntax, which requires <%= and not <% on form_for to generate output; fixed syntax in migration since Time.parse and Date.parse take month/day args in opposite order in ruby 1.9 - rspec (2.6.0) - rspec-core (~> 2.6.0) - rspec-expectations (~> 2.6.0) - rspec-mocks (~> 2.6.0) - rspec-core (2.6.4) - rspec-expectations (2.6.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.6.0) - rspec-rails (2.6.1) - actionpack (~> 3.0) - activesupport (~> 3.0) - railties (~> 3.0) - rspec (~> 2.6.0) -<<<<<<< HEAD - ruby-debug (0.10.4) - columnize (>= 0.1) - ruby-debug-base (~> 0.10.4.0) - ruby-debug-base (0.10.4) - linecache (>= 0.3) - ruby-tmdb (0.2.1) - addressable - deepopenstruct (>= 0.1.2) - json -======= ruby-debug-base19 (0.11.25) columnize (>= 0.3.1) linecache19 (>= 0.5.11) @@ -147,46 +99,37 @@ GEM ruby-debug-base19 (>= 0.11.19) ruby_core_source (0.1.5) archive-tar-minitar (>= 0.5.2) ->>>>>>> e60314f... Updated gems to correct versions; updated form partial (at least one of them) to use new form_for syntax, which requires <%= and not <% on form_for to generate output; fixed syntax in migration since Time.parse and Date.parse take month/day args in opposite order in ruby 1.9 - rubyzip (0.9.4) - selenium-webdriver (2.9.1) - childprocess (>= 0.2.1) - ffi (= 1.0.9) - json_pure - rubyzip + sass (3.1.10) + sass-rails (3.1.5) + actionpack (~> 3.1.0) + railties (~> 3.1.0) + sass (~> 3.1.10) + tilt (~> 1.3.2) sprockets (2.0.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.4) - term-ansicolor (1.0.7) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.30) - xpath (0.1.4) - nokogiri (~> 1.3) + tzinfo (0.3.31) + uglifier (1.1.0) + execjs (>= 0.3.0) + multi_json (>= 1.0.2) PLATFORMS ruby DEPENDENCIES - capybara - cucumber - cucumber-rails + coffee-rails (~> 3.1.0) haml - rails (= 3.1) -<<<<<<< HEAD - rcov - rspec-rails - ruby-debug - ruby-tmdb -======= - rake (= 0.8.7) - rspec - rspec-rails + jquery-rails + railroady + rails (= 3.1.0) ruby-debug19 ->>>>>>> e60314f... Updated gems to correct versions; updated form partial (at least one of them) to use new form_for syntax, which requires <%= and not <% on form_for to generate output; fixed syntax in migration since Time.parse and Date.parse take month/day args in opposite order in ruby 1.9 - sqlite3 (~> 1.3.3) + sass-rails (~> 3.1.0) + sqlite3 + uglifier diff --git a/README b/README index 408cdb966..7c36f2356 100644 --- a/README +++ b/README @@ -1,15 +1,3 @@ -== RottenPotatoes for "Engineering Software for Cloud Computing" - -This repo tracks the version of the RottenPotatoes teaching app used -with the Fox & Patterson textbook "Engineering Software for Cloud -Computing". - -Different branches of the repo correspond to the code developed in -different chapters of the book. - -See the book for information on how to use this repo and what the -branches are for. - == Welcome to Rails Rails is a web-application framework that includes everything needed to create @@ -38,39 +26,6 @@ Rails. You can read more about Action Pack in link:files/vendor/rails/actionpack/README.html. -== Getting Started - -NOTE: The steps below are for creating a new app. The initial version -of RottenPotatoes was created with Rails 3.0.5 and Ruby 1.8.7 using the -commands: - -* rails new rottenpotatoes -J -T -* cd rottenpotatoes -* rails generate resource movie title:string rating:string description:text released_on:datetime -* rake db:migrate -* rails generate cucumber:install -* rails generate rspec:install -* rm public/index.html - -and then filling in the basic code for the Movie model, views and controller. - -1. At the command prompt, create a new Rails application: - rails new myapp (where myapp is the application name) - -2. Change directory to myapp and start the web server: - cd myapp; rails server (run with --help for options) - -3. Go to http://localhost:3000/ and you'll see: - "Welcome aboard: You're riding Ruby on Rails!" - -4. Follow the guidelines to start developing your application. You can find -the following resources handy: - -* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html -* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ - - - == Getting Started 1. At the command prompt, create a new Rails application: @@ -136,7 +91,7 @@ mode. With gems, use sudo gem install ruby-debug. Example: class WeblogController < ActionController::Base def index - @posts = Post.find(:all) + @posts = Post.all debugger end end @@ -184,7 +139,7 @@ To reload your controllers and models after launching the console run reload! More information about irb can be found at: -link:http://www.rubycentral.com/pickaxe/irb.html +link:http://www.rubycentral.org/pickaxe/irb.html == dbconsole @@ -201,6 +156,10 @@ PostgreSQL and SQLite 3. The default directory structure of a generated Ruby on Rails application: |-- app + | |-- assets + | |-- images + | |-- javascripts + | `-- stylesheets | |-- controllers | |-- helpers | |-- mailers @@ -217,9 +176,6 @@ The default directory structure of a generated Ruby on Rails application: | `-- tasks |-- log |-- public - | |-- images - | |-- javascripts - | `-- stylesheets |-- script |-- test | |-- fixtures @@ -233,11 +189,16 @@ The default directory structure of a generated Ruby on Rails application: | |-- sessions | `-- sockets `-- vendor + |-- assets + `-- stylesheets `-- plugins app Holds all the code that's specific to this particular application. +app/assets + Contains subdirectories for images, stylesheets, and JavaScript files. + app/controllers Holds controllers that should be named like weblogs_controller.rb for automated URL mapping. All controllers should descend from @@ -282,8 +243,7 @@ lib the load path. public - The directory available for the web server. Contains subdirectories for - images, stylesheets, and javascripts. Also contains the dispatchers and the + The directory available for the web server. Also contains the dispatchers and the default HTML files. This should be set as the DOCUMENT_ROOT of your web server. diff --git a/Rakefile b/Rakefile index 21125b299..3a6294535 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ +#!/usr/bin/env rake # 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 File.expand_path('../config/application', __FILE__) -require 'rake' Rottenpotatoes::Application.load_tasks diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png new file mode 100644 index 000000000..d5edc04e6 Binary files /dev/null and b/app/assets/images/rails.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 000000000..37c7bfcdb --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,9 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require jquery +//= require jquery_ujs +//= require_tree . diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 000000000..42fe63db2 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,7 @@ +/* + * This is a manifest file that'll automatically include all the stylesheets available in this directory + * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at + * the top of the compiled file, but it's generally better to create a new file per style scope. + *= require_self + *= require_tree . +*/ diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index df2daf8f1..4ea15bcb6 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,53 +1,33 @@ class MoviesController < ApplicationController - def index - @movies = Movie.find(:all, :order => 'release_date') - end - - def search_tmdb - @movies = Movie.find_in_tmdb(params[:search_terms]) + def show + id = params[:id] # retrieve movie ID from URI route + @movie = Movie.find(id) # look up movie by unique ID + # will render app/views/movies/show. by default end - def new - @movie = Movie.new - end - + # in movies_controller.rb def create - @movie = Movie.new(params[:movie]) - if @movie.save - flash[:notice] = "#{@movie.title} added to Rotten Potatoes!" - redirect_to movie_path(@movie) - else - render :action => "new" - end + Movie.create!(params[:movie]) + redirect_to movies_path end - - def show - @movie = Movie.find(params[:id]) + def index + @movies = Movie.all end - + def new + end + # in movies_controller.rb + def edit - @movie = Movie.find(params[:id]) + @movie = Movie.find params[:id] end - + def update - @movie = Movie.find(params[:id]) - if @movie.update_attributes(params[:movie]) - flash[:notice] = "#{@movie.title} has been updated!" - redirect_to movie_path(@movie) - else - render :action => "edit" - end + @movie = Movie.find params[:id] + @movie.update_attributes!(params[:movie]) + redirect_to movie_path(@movie) end - def destroy - @movie = Movie.find(params[:id]) - if @movie.destroy - flash[:notice] = "#{@movie.title} has been deleted!" - else - flash[:error] = "Failed to delete #{@movie.title}!" - end - redirect_to(movies_url) - end + end diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/app/models/movie.rb b/app/models/movie.rb index d41d33005..49198a7d9 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -1,20 +1,2 @@ class Movie < ActiveRecord::Base - - class InvalidKeyError < StandardError ; end - - def self.api_key - 'cc4b67c52acb514bdf4931f7cedfd12b' - end - - def self.find_in_tmdb(string) - Tmdb.api_key = self.api_key - begin - TmdbMovie.find(:title => string) - rescue ArgumentError => tmdb_error - raise Movie::InvalidKeyError, tmdb_error.message - rescue RuntimeError => tmdb_error - raise Movie::InvalidKeyError, tmdb_error.message - end - end - end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 000000000..749e4b498 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Rottenpotatoes + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/app/views/movies/_movie_form.html.haml b/app/views/movies/_movie_form.html.haml new file mode 100644 index 000000000..a68ccbc23 --- /dev/null +++ b/app/views/movies/_movie_form.html.haml @@ -0,0 +1,11 @@ +-# in _movie_form.html.haml (the partial) + += label :movie, :title, 'Title' += text_field :movie, 'title' + += label :movie, :rating, 'Rating' += select :movie, :rating, ['G','PG','PG-13','R','NC-17'] + += label :movie, :release_date, 'Released On' += date_select :movie, :release_date + diff --git a/app/views/movies/edit.html.haml b/app/views/movies/edit.html.haml index f028fda89..26c8fdeb5 100644 --- a/app/views/movies/edit.html.haml +++ b/app/views/movies/edit.html.haml @@ -1,7 +1,7 @@ -%h2 Editing #{@movie.title} +-# edit.html.haml using partial -= render :partial => "edit_form" +%h1 Edit Existing Movie -%ul#page_nav - %li= link_to "Cancel and back to #{@movie.name}", @movie - %li= link_to "Cancel and go Back to list of movies", movies_path += form_tag movie_path(@movie), :method => :put do + = render :partial => 'movie_form' + = submit_tag 'Update Movie Info' diff --git a/app/views/movies/index.html.haml b/app/views/movies/index.html.haml index 087057e06..449cae0b7 100644 --- a/app/views/movies/index.html.haml +++ b/app/views/movies/index.html.haml @@ -1,6 +1,7 @@ -%h2 All Movies +-# This file is app/views/movies/index.html.haml +%h1 All Movies -%table#movies{:summary => 'List of all the movies.'} +%table#movies %thead %tr %th Movie Title @@ -8,13 +9,9 @@ %th Release Date %th More Info %tbody - - @movies.each_with_index do |movie,count| - %tr{:class => oddness(count)} + - @movies.each do |movie| + %tr %td= movie.title %td= movie.rating %td= movie.release_date - %td= link_to 'More about #{movie.title}', movie - -%ul#page_nav - %li= link_to 'Add New Movie Manually', new_movie_path - + %td= link_to "More about #{movie.title}", movie diff --git a/app/views/movies/new.html.haml b/app/views/movies/new.html.haml index 8959d73d7..8da166974 100644 --- a/app/views/movies/new.html.haml +++ b/app/views/movies/new.html.haml @@ -1,6 +1,6 @@ -%h2 Add New Movie +%h1 Create New Movie -= render :partial => "edit_form" += form_tag movies_path do -%ul#page_nav - %li= link_to "Cancel and go back to list of movies", movies_path + = render :partial => 'movie_form' + = submit_tag 'Save Changes' diff --git a/app/views/movies/show.html.haml b/app/views/movies/show.html.haml index 9589b37cd..10ef4dc79 100644 --- a/app/views/movies/show.html.haml +++ b/app/views/movies/show.html.haml @@ -1,10 +1,18 @@ -%h2= @movie.title +-# in app/views/movies/show.html.haml -%p - Released on #{@movie.release_date.to_formatted_s}. Rated #{@movie.rating}. - = simple_format(@movie.description) +%h2 Details about #{@movie.title} -%ul#page_nav - %li= link_to 'Edit', edit_movie_path(@movie) - %li= link_to 'Delete', movie_path(@movie), :method => :delete, :confirm => "Really delete #{@movie.title}?" - %li= link_to 'Back to list of movies', movies_path +%ul#details + %li + Rating: + = @movie.rating + %li + Released on: + = @movie.release_date.strftime("%B %d, %Y") + +%h3 Description: + +%p#description= @movie.description + += link_to 'Edit', edit_movie_path(@movie) += link_to 'Back to movie list', movies_path diff --git a/config/application.rb b/config/application.rb index b0c7909a9..8e9d6e04f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,10 +1,19 @@ require File.expand_path('../boot', __FILE__) -require 'rails/all' - -# If you have a Gemfile, require the gems listed there, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(:default, Rails.env) if defined?(Bundler) +# Pick the frameworks you want: +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "active_resource/railtie" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require *Rails.groups(:assets => %w(development test)) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end module Rottenpotatoes class Application < Rails::Application @@ -30,13 +39,16 @@ class Application < Rails::Application # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - # JavaScript files you want as :defaults (application.js is always included). - config.action_view.javascript_expansions[:defaults] = %w() - # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] + + # Enable the asset pipeline + config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' end end diff --git a/config/database.yml b/config/database.yml index ad7d69975..51a4dd459 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,5 +1,8 @@ # SQLite version 3.x # gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' development: adapter: sqlite3 database: db/development.sqlite3 @@ -9,7 +12,7 @@ development: # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. -test: &test +test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 @@ -20,6 +23,3 @@ production: database: db/production.sqlite3 pool: 5 timeout: 5000 - -cucumber: - <<: *test \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 129c4b633..b3ea037b2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,7 +3,7 @@ # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development - # since you don't have to restart the webserver when you make code changes. + # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. @@ -11,7 +11,6 @@ # Show full error reports and disable caching config.consider_all_requests_local = true - config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send @@ -22,5 +21,10 @@ # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin -end + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb index cff0d886e..63f9e68cd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,7 +1,6 @@ Rottenpotatoes::Application.configure do # Settings specified here will take precedence over those in config/application.rb - # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true @@ -9,14 +8,27 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = "X-Sendfile" + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true - # For nginx: - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH - # If you have no front-end server that supports something like X-Sendfile, - # just comment this out and Rails will serve the files + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true # See everything in the log (default is :info) # config.log_level = :debug @@ -27,13 +39,12 @@ # Use a different cache store in production # config.cache_store = :mem_cache_store - # Disable Rails's static asset server - # In production, Apache or nginx will already do this - config.serve_static_assets = false - - # Enable serving of images, stylesheets, and javascripts from an asset server + # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false diff --git a/config/environments/test.rb b/config/environments/test.rb index 5af6a68f3..61cc3b17c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -7,7 +7,11 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil config.whiny_nils = true # Show full error reports and disable caching @@ -32,4 +36,7 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets + config.assets.allow_debugging = true end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 8f5578df9..cbfb63373 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -Rottenpotatoes::Application.config.secret_token = '34b98b325dd4a08e0e2ab75dcfd9ee3c8c0337daa64e2fce0e71b8545c52d7125e27c6edba1ae7b63bedca6cc1d8aea7ff73c337fa110fad98eb77dafa953159' +Rottenpotatoes::Application.config.secret_token = '683d4dea01b4bc5f21a276ea8cedf23a4f26d44d8e8680a2c16fb0c10ee60daae78896b37cce798dc793dc270bc7c1325ab83b175c6b35aea8e2cb2d19a25f8f' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 474ba6602..6a8e3fc91 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,6 +1,6 @@ # Be sure to restart your server when you modify this file. -Rottenpotatoes::Application.config.session_store :cookie_store, :key => '_rottenpotatoes_session' +Rottenpotatoes::Application.config.session_store :cookie_store, key: '_rottenpotatoes_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 000000000..999df2018 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# Disable root element in JSON by default. +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false +end diff --git a/config/locales/en.yml b/config/locales/en.yml index a747bfa69..179c14ca5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,5 @@ # Sample localization file for English. Add more files in this directory for other locales. -# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. en: hello: "Hello world" diff --git a/config/routes.rb b/config/routes.rb index 51e3ec1cb..18a27b40d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,12 +1,59 @@ Rottenpotatoes::Application.routes.draw do - # create RESTful routes for the Movie resource. + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products resources :movies - # The root of the site ('/') is an alias for 'list all movies'. - root :to => 'movies#index' + # Sample resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end - # Otherwise, assume the route names the controller and action - match ':controller/:action' + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + # root :to => 'welcome#index' # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + # match ':controller(/:action(/:id(.:format)))' end diff --git a/db/migrate/20110909213200_create_movies.rb b/db/migrate/20111119180638_create_movies.rb similarity index 66% rename from db/migrate/20110909213200_create_movies.rb rename to db/migrate/20111119180638_create_movies.rb index 4cfbfa1e8..c20bdaef1 100644 --- a/db/migrate/20110909213200_create_movies.rb +++ b/db/migrate/20111119180638_create_movies.rb @@ -1,15 +1,17 @@ class CreateMovies < ActiveRecord::Migration - def self.up + def up create_table :movies do |t| t.string :title t.string :rating t.text :description t.datetime :release_date + # Add fields that let Rails automatically keep track + # of when movies are added or modified: t.timestamps end end - def self.down + def down drop_table :movies end end diff --git a/db/seeds.rb b/db/seeds.rb index 664d8c74c..4edb1e857 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3,5 +3,5 @@ # # Examples: # -# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Mayor.create(:name => 'Daley', :city => cities.first) +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/public/index.html b/public/index.html new file mode 100644 index 000000000..9d9811a5b --- /dev/null +++ b/public/index.html @@ -0,0 +1,241 @@ + + + + Ruby on Rails: Welcome aboard + + + + +
+ + +
+ + + + +
+

Getting started

+

Here’s how to get rolling:

+ +
    +
  1. +

    Use rails generate to create your models and controllers

    +

    To see all available options, run it without parameters.

    +
  2. + +
  3. +

    Set up a default route and remove public/index.html

    +

    Routes are set up in config/routes.rb.

    +
  4. + +
  5. +

    Create your database

    +

    Run rake db:create to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    +
  6. +
+
+
+ + +
+ +