feedback_with_country_state 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +34 -0
  4. data/app/assets/javascripts/feedback_with_country_state/application.js +13 -0
  5. data/app/assets/javascripts/feedback_with_country_state/users.js +20 -0
  6. data/app/assets/stylesheets/feedback_with_country_state/application.css +13 -0
  7. data/app/assets/stylesheets/feedback_with_country_state/users.css +4 -0
  8. data/app/controllers/feedback_with_country_state/application_controller.rb +4 -0
  9. data/app/controllers/feedback_with_country_state/users_controller.rb +40 -0
  10. data/app/helpers/feedback_with_country_state/application_helper.rb +4 -0
  11. data/app/helpers/feedback_with_country_state/users_helper.rb +4 -0
  12. data/app/models/feedback_with_country_state/country.rb +5 -0
  13. data/app/models/feedback_with_country_state/state.rb +5 -0
  14. data/app/models/feedback_with_country_state/user.rb +6 -0
  15. data/app/views/feedback_with_country_state/users/index.html.erb +1 -0
  16. data/app/views/feedback_with_country_state/users/new.html.erb +37 -0
  17. data/app/views/feedback_with_country_state/users/show.html.erb +28 -0
  18. data/app/views/layouts/feedback_with_country_state/application.html.erb +15 -0
  19. data/config/routes.rb +4 -0
  20. data/db/migrate/20131120142341_create_feedback_with_country_state_users.rb +13 -0
  21. data/db/migrate/20131120142358_create_feedback_with_country_state_countries.rb +10 -0
  22. data/db/migrate/20131120142405_create_feedback_with_country_state_states.rb +11 -0
  23. data/db/seeds.rb +17 -0
  24. data/lib/feedback_with_country_state.rb +4 -0
  25. data/lib/feedback_with_country_state/engine.rb +5 -0
  26. data/lib/feedback_with_country_state/version.rb +3 -0
  27. data/lib/tasks/feedback_with_country_state_tasks.rake +4 -0
  28. data/test/controllers/feedback_with_country_state/users_controller_test.rb +9 -0
  29. data/test/dummy/README.rdoc +28 -0
  30. data/test/dummy/Rakefile +6 -0
  31. data/test/dummy/app/assets/javascripts/application.js +13 -0
  32. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  33. data/test/dummy/app/controllers/application_controller.rb +5 -0
  34. data/test/dummy/app/helpers/application_helper.rb +2 -0
  35. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  36. data/test/dummy/bin/bundle +3 -0
  37. data/test/dummy/bin/rails +4 -0
  38. data/test/dummy/bin/rake +4 -0
  39. data/test/dummy/config.ru +4 -0
  40. data/test/dummy/config/application.rb +23 -0
  41. data/test/dummy/config/boot.rb +5 -0
  42. data/test/dummy/config/database.yml +25 -0
  43. data/test/dummy/config/environment.rb +5 -0
  44. data/test/dummy/config/environments/development.rb +29 -0
  45. data/test/dummy/config/environments/production.rb +80 -0
  46. data/test/dummy/config/environments/test.rb +36 -0
  47. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  48. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/test/dummy/config/initializers/inflections.rb +16 -0
  50. data/test/dummy/config/initializers/mime_types.rb +5 -0
  51. data/test/dummy/config/initializers/secret_token.rb +12 -0
  52. data/test/dummy/config/initializers/session_store.rb +3 -0
  53. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/test/dummy/config/locales/en.yml +23 -0
  55. data/test/dummy/config/routes.rb +4 -0
  56. data/test/dummy/countries.csv +246 -0
  57. data/test/dummy/db/development.sqlite3 +0 -0
  58. data/test/dummy/db/schema.rb +41 -0
  59. data/test/dummy/db/seeds.rb +17 -0
  60. data/test/dummy/db/test.sqlite3 +0 -0
  61. data/test/dummy/log/development.log +8021 -0
  62. data/test/dummy/public/404.html +58 -0
  63. data/test/dummy/public/422.html +58 -0
  64. data/test/dummy/public/500.html +57 -0
  65. data/test/dummy/public/favicon.ico +0 -0
  66. data/test/dummy/states.csv +1626 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/00a4f98286c23052abf232d6878da82a +0 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/0419fefceda5a67a222cb6f6478f498f +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/0ab64614ef25980ac4cf9e81a9892a44 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/0bcb67bba77f8632667ed7013faed456 +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/17b435992d09784986690dfdbe6906b0 +0 -0
  72. data/test/dummy/tmp/cache/assets/development/sprockets/2560397becd6c9f617c58941ba7216db +0 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/30069ac6f8471fb464c289506e9ed054 +0 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/3a8794bf66ac5ed1a9b87737368dac39 +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sprockets/b2676dd62f215a196fb93a8e3e0fcfc9 +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/c47eceec5a8c481e3aba47c384f198b5 +0 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/c9c2dd6386bf37dc338ae1e7d8daaf4d +0 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/f71897be8009100a97eeb34ec367abbc +0 -0
  79. data/test/feedback_with_country_state_test.rb +7 -0
  80. data/test/fixtures/feedback_with_country_state/countries.yml +9 -0
  81. data/test/fixtures/feedback_with_country_state/states.yml +11 -0
  82. data/test/fixtures/feedback_with_country_state/users.yml +15 -0
  83. data/test/helpers/feedback_with_country_state/users_helper_test.rb +6 -0
  84. data/test/integration/navigation_test.rb +10 -0
  85. data/test/models/feedback_with_country_state/country_test.rb +9 -0
  86. data/test/models/feedback_with_country_state/state_test.rb +9 -0
  87. data/test/models/feedback_with_country_state/user_test.rb +9 -0
  88. data/test/test_helper.rb +15 -0
  89. metadata +226 -0
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = FeedbackWithCountryState
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'FeedbackWithCountryState'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,20 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
3
+ $(function() {
4
+ var states;
5
+ $('#user_state_id').parent().hide();
6
+ states = $('#user_state_id').html();
7
+ return $('#user_country_id').change(function() {
8
+ var country, escaped_country, options;
9
+ country = $('#user_country_id :selected').text();
10
+ escaped_country = country.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
11
+ options = $(states).filter("optgroup[label='" + escaped_country + "']").html();
12
+ if (options) {
13
+ $('#user_state_id').html(options);
14
+ return $('#user_state_id').parent().show();
15
+ } else {
16
+ $('#user_state_id').empty();
17
+ return $('#user_state_id').parent().hide();
18
+ }
19
+ });
20
+ });
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ module FeedbackWithCountryState
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,40 @@
1
+ require_dependency "feedback_with_country_state/application_controller"
2
+
3
+ module FeedbackWithCountryState
4
+ class UsersController < ApplicationController
5
+ before_action :set_user, only: [:show]
6
+ def index
7
+ @users = User.all
8
+ end
9
+
10
+
11
+ def show
12
+ end
13
+
14
+ def new
15
+ @user = User.new
16
+ end
17
+
18
+
19
+ def create
20
+ @user = User.new(user_params)
21
+
22
+ if @user.save
23
+ redirect_to @user, notice: 'User was successfully created.'
24
+ else
25
+ render action: 'new'
26
+ end
27
+ end
28
+
29
+
30
+ private
31
+ def set_user
32
+ @user = User.find(params[:id])
33
+ end
34
+
35
+ def user_params
36
+ debugger
37
+ params.require(:user).permit(:name, :email, :country_id, :state_id, :comment)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,4 @@
1
+ module FeedbackWithCountryState
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module FeedbackWithCountryState
2
+ module UsersHelper
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ module FeedbackWithCountryState
2
+ class Country < ActiveRecord::Base
3
+ has_many :states
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module FeedbackWithCountryState
2
+ class State < ActiveRecord::Base
3
+ belongs_to :country
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module FeedbackWithCountryState
2
+ class User < ActiveRecord::Base
3
+ has_many :countries
4
+ has_many :states
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ <%= link_to "Feedback", new_user_path%>
@@ -0,0 +1,37 @@
1
+ <%= form_for(@user) do |f| %>
2
+ <% if @user.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @user.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :email %><br>
20
+ <%= f.text_field :email %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :country_id %><br>
24
+ <%= f.collection_select :country_id, FeedbackWithCountryState::Country.order(:name), :id, :name, include_blank: true %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :state_id %><br>
28
+ <%= f.grouped_collection_select :state_id, FeedbackWithCountryState::Country.order(:name), :states, :name, :id, :name, include_blank: true %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :comment %><br>
32
+ <%= f.text_area :comment, :style=>"width: 336px; height: 143px;"%>
33
+ </div>
34
+ <div class="actions">
35
+ <%= f.submit %>
36
+ </div>
37
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <p id="notice"><%= notice %></p>
2
+ <%debugger%>
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @user.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Email:</strong>
10
+ <%= @user.email %>
11
+ </p>
12
+
13
+ <p>
14
+ <strong>Country:</strong>
15
+ <%= FeedbackWithCountryState::Country.find(@user.country_id).name %>
16
+ </p>
17
+
18
+ <p>
19
+ <strong>State:</strong>
20
+ <%= FeedbackWithCountryState::State.find(@user.state_id).name %>
21
+ </p>
22
+
23
+ <p>
24
+ <strong>Comment:</strong>
25
+ <%= @user.comment %>
26
+ </p>
27
+
28
+
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>FeedbackWithCountryState</title>
5
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
6
+ <%= stylesheet_link_tag "feedback_with_country_state/application", media: "all" %>
7
+ <%= javascript_include_tag "feedback_with_country_state/application" %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,4 @@
1
+ FeedbackWithCountryState::Engine.routes.draw do
2
+ resources :users
3
+ root to: "users#index"
4
+ end
@@ -0,0 +1,13 @@
1
+ class CreateFeedbackWithCountryStateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :feedback_with_country_state_users do |t|
4
+ t.string :name
5
+ t.string :email
6
+ t.integer :country_id
7
+ t.integer :state_id
8
+ t.text :comment
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class CreateFeedbackWithCountryStateCountries < ActiveRecord::Migration
2
+ def change
3
+ create_table :feedback_with_country_state_countries do |t|
4
+ t.string :name
5
+ t.string :abbreviation
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ class CreateFeedbackWithCountryStateStates < ActiveRecord::Migration
2
+ def change
3
+ create_table :feedback_with_country_state_states do |t|
4
+ t.integer :country_id
5
+ t.string :name
6
+ t.string :abbreviation
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ require 'csv'
2
+
3
+ puts "Importing countries..."
4
+ CSV.foreach("/home/cis/Desktop/feedback_with_country_state/test/dummy/countries.csv") do |row|
5
+ FeedbackWithCountryState::Country.create! do |country|
6
+ country.id = row[0]
7
+ country.name = row[1]
8
+ end
9
+ end
10
+
11
+ puts "Importing states..."
12
+ CSV.foreach("/home/cis/Desktop/feedback_with_country_state/test/dummy/states.csv") do |row|
13
+ FeedbackWithCountryState::State.create! do |state|
14
+ state.name = row[0]
15
+ state.country_id = row[2]
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ require "feedback_with_country_state/engine"
2
+
3
+ module FeedbackWithCountryState
4
+ end
@@ -0,0 +1,5 @@
1
+ module FeedbackWithCountryState
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace FeedbackWithCountryState
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module FeedbackWithCountryState
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :feedback_with_country_state do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module FeedbackWithCountryState
4
+ class UsersControllerTest < ActionController::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
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
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */