├── lib └── tasks │ └── .gitkeep ├── public ├── favicon.ico ├── stylesheets │ └── .gitkeep ├── robots.txt ├── 422.html ├── 404.html └── 500.html ├── .rspec ├── vendor └── plugins │ └── .gitkeep ├── app ├── helpers │ ├── comments_helper.rb │ └── application_helper.rb ├── views │ ├── comments │ │ ├── destroy.js.erb │ │ ├── edit.html.erb │ │ ├── new.html.erb │ │ ├── show.html.erb │ │ ├── index.html.erb │ │ ├── _new_comment_links.html.erb │ │ ├── _comment.html.erb │ │ ├── create.js.erb │ │ └── _form.html.erb │ └── layouts │ │ └── application.html.erb ├── assets │ ├── images │ │ └── rails.png │ ├── stylesheets │ │ ├── application.css │ │ └── scaffold.css │ └── javascripts │ │ ├── application.js │ │ └── comments.js ├── controllers │ ├── application_controller.rb │ └── comments_controller.rb └── models │ └── comment.rb ├── .gitignore ├── config.ru ├── config ├── environment.rb ├── boot.rb ├── initializers │ ├── mime_types.rb │ ├── inflections.rb │ ├── backtrace_silencers.rb │ ├── session_store.rb │ └── secret_token.rb ├── locales │ └── en.yml ├── database.yml ├── environments │ ├── development.rb │ ├── test.rb │ └── production.rb ├── routes.rb └── application.rb ├── doc └── README_FOR_APP ├── .travis.yml ├── Rakefile ├── script └── rails ├── db ├── migrate │ ├── 20110209210252_create_comments.rb │ └── 20110209210315_add_attachment_to_comment.rb ├── seeds.rb └── schema.rb ├── Gemfile ├── spec ├── support │ └── integration_helper.rb ├── spec_helper.rb └── features │ └── comments_spec.rb ├── gemfiles ├── 3.2.gemfile ├── 4.0.gemfile ├── 4.1.gemfile └── 4.2.gemfile └── README.md /lib/tasks/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --colour 2 | -------------------------------------------------------------------------------- /vendor/plugins/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/stylesheets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/helpers/comments_helper.rb: -------------------------------------------------------------------------------- 1 | module CommentsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/views/comments/destroy.js.erb: -------------------------------------------------------------------------------- 1 | $('#comment-<%= @comment.id %>').remove(); 2 | -------------------------------------------------------------------------------- /app/assets/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JangoSteve/Rails-jQuery-Demo/HEAD/app/assets/images/rails.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | db/*.sqlite3 3 | log/*.log 4 | tmp/ 5 | *.swp 6 | .rvmrc 7 | public/system/* 8 | Gemfile.lock 9 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | end 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * FIXME: Introduce SCSS & Sprockets 3 | *= require 'scaffold' 4 | *= require_self 5 | *= require_tree . 6 | */ 7 | -------------------------------------------------------------------------------- /app/views/comments/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing comment

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @comment %> | 6 | <%= link_to 'Back', comments_path %> 7 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run JqueryRails::Application 5 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | JqueryRails::Application.initialize! 6 | -------------------------------------------------------------------------------- /app/models/comment.rb: -------------------------------------------------------------------------------- 1 | class Comment < ActiveRecord::Base 2 | has_attached_file :attachment 3 | validates :subject, :body, :presence => true 4 | do_not_validate_attachment_file_type :attachment 5 | end 6 | -------------------------------------------------------------------------------- /app/views/comments/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

New comment

3 | 4 | <%= render 'form' %> 5 | 6 | <%= link_to 'Cancel', comments_path, :id => 'cancel-button' %> 7 |
8 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | # Set up gems listed in the Gemfile. 4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 5 | 6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 7 | -------------------------------------------------------------------------------- /doc/README_FOR_APP: -------------------------------------------------------------------------------- 1 | Use this README file to introduce your application and point to useful places in the API for learning more. 2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // FIXME: Tell people that this is a manifest file, real code should go into discrete files 2 | // FIXME: Tell people how Sprockets and CoffeeScript works 3 | // 4 | //= require jquery 5 | //= require jquery_ujs 6 | //= require_tree . 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 1.9.3 4 | - 2.0.0 5 | - 2.1.1 6 | - 2.1.5 7 | env: 8 | - "RAILS_VERSION=3.2" 9 | - "RAILS_VERSION=4.0" 10 | - "RAILS_VERSION=4.1" 11 | - "RAILS_VERSION=4.2" 12 | script: 13 | - RAILS_ENV=test xvfb-run bundle exec rspec -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | require 'rake' 6 | 7 | JqueryRails::Application.load_tasks 8 | -------------------------------------------------------------------------------- /app/views/comments/show.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | <%= render @comment %> 11 |
SubjectBodyAttachment
12 | 13 |
14 | 15 | <%= link_to 'Back', comments_path %> 16 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JqueryRails 5 | <%= stylesheet_link_tag "application" %> 6 | <%= javascript_include_tag "application" %> 7 | <%= csrf_meta_tag %> 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 3 | 4 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /db/migrate/20110209210252_create_comments.rb: -------------------------------------------------------------------------------- 1 | class CreateComments < ActiveRecord::Migration 2 | def self.up 3 | create_table :comments do |t| 4 | t.string :subject 5 | t.text :body 6 | 7 | t.timestamps 8 | end 9 | end 10 | 11 | def self.down 12 | drop_table :comments 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | rails_version = ENV["RAILS_VERSION"] || "default" 4 | 5 | rails = case rails_version 6 | when "default" 7 | "~> 3.2.0" 8 | else 9 | "~> #{rails_version}" 10 | end 11 | 12 | version = ENV["RAILS_VERSION"] || "3.2" 13 | 14 | eval_gemfile File.expand_path("../gemfiles/#{version}.gemfile", __FILE__) -------------------------------------------------------------------------------- /app/views/comments/index.html.erb: -------------------------------------------------------------------------------- 1 |

Listing comments

2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | <%= render @comments %> 14 |
SubjectBodyAttachment 8 |
15 | 16 |
17 | 18 | <%= render 'new_comment_links' %> 19 | -------------------------------------------------------------------------------- /app/views/comments/_new_comment_links.html.erb: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) 7 | # Mayor.create(:name => 'Daley', :city => cities.first) 8 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | JqueryRails::Application.config.session_store :cookie_store, :key => '_jquery-rails_session' 4 | 5 | # Use the database for sessions instead of the cookie-based default, 6 | # which shouldn't be used to store highly confidential information 7 | # (create the session table with "rails generate session_migration") 8 | # JqueryRails::Application.config.session_store :active_record_store 9 | -------------------------------------------------------------------------------- /app/views/comments/_comment.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= comment.subject %> 3 | <%= comment.body %> 4 | <%= link_to comment.attachment_file_name, comment.attachment.url if comment.attachment? %> 5 | <%= link_to 'Show', comment %> 6 | <%= link_to 'Edit', edit_comment_path(comment) %> 7 | <%= link_to 'Destroy', comment, :confirm => 'Are you sure?', :method => :delete, :remote => true %> 8 | 9 | -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | JqueryRails::Application.config.secret_token = '14d748ccb7bec478834026d9ccd18693720043771abe1482a5de414d7e5c8e2bd1bff76c5c3fb23f1416cd733621cdf8da87b0ee6921c39af39cf6a71de399ad' 8 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | development: 4 | adapter: sqlite3 5 | database: db/development.sqlite3 6 | pool: 5 7 | timeout: 5000 8 | 9 | # Warning: The database defined as "test" will be erased and 10 | # re-generated from your development database when you run "rake". 11 | # Do not set this db to the same as development or production. 12 | test: 13 | adapter: sqlite3 14 | database: ":memory:" 15 | 16 | production: 17 | adapter: sqlite3 18 | database: db/production.sqlite3 19 | pool: 5 20 | timeout: 5000 21 | -------------------------------------------------------------------------------- /app/views/comments/create.js.erb: -------------------------------------------------------------------------------- 1 | <% unless @comment.errors.any? %> 2 | $('#comments').append( '<%= escape_javascript( 3 | render @comment 4 | ) %>' ); 5 | $('#new-comment-form-container').find('input:not(:submit),select,textarea').val(''); 6 | <% else %> 7 | var $form = $('#new_comment'), 8 | $errorDiv = $('
'), 9 | $errorList = $('