created subcategories
This commit is contained in:
3
Gemfile
3
Gemfile
@@ -23,6 +23,9 @@ gem 'jbuilder', '~> 2.0'
|
||||
# bundle exec rake doc:rails generates the API under doc/api.
|
||||
gem 'sdoc', '~> 0.4.0', group: :doc
|
||||
|
||||
# great server
|
||||
gem 'puma'
|
||||
|
||||
# Use ActiveModel has_secure_password
|
||||
# gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ GEM
|
||||
nokogiri (1.6.5)
|
||||
mini_portile (~> 0.6.0)
|
||||
pg (0.18.1)
|
||||
puma (2.10.2)
|
||||
rack (>= 1.1, < 2.0)
|
||||
rack (1.6.0)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
@@ -164,6 +166,7 @@ DEPENDENCIES
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
pg
|
||||
puma
|
||||
rails (= 4.2.0)
|
||||
sass-rails (~> 5.0)
|
||||
sdoc (~> 0.4.0)
|
||||
|
||||
27
README.md
27
README.md
@@ -1,2 +1,27 @@
|
||||
# ribica-back-office
|
||||
# Ribica Back Office
|
||||
|
||||
Rails interface for administration
|
||||
|
||||
## Configuration
|
||||
|
||||
Configure config/database.yml to point to same database as config.rb in front office
|
||||
|
||||
## Active scaffold
|
||||
|
||||
Customization documentation is here: http://activescaffold.com/
|
||||
|
||||
Example of generating scaffold for category model
|
||||
|
||||
`rails g active_scaffold Category name:string`
|
||||
|
||||
## Handling shared models
|
||||
|
||||
Some of models will necesarrily be shared between front and back office.
|
||||
Migrations for those models *must be in front office* and
|
||||
back office will just have a model file with custom code if needed.
|
||||
The reason is that we want front office to be standalone with a different
|
||||
backoffice (for sellingtechnology to other businesses and stuff).
|
||||
|
||||
When generating active scaffold - migration is generated by default so it
|
||||
needs to be removed before using it.
|
||||
|
||||
|
||||
28
README.rdoc
28
README.rdoc
@@ -1,28 +0,0 @@
|
||||
== README
|
||||
|
||||
This README would normally document whatever steps are necessary to get the
|
||||
application up and running.
|
||||
|
||||
Things you may want to cover:
|
||||
|
||||
* Ruby version
|
||||
|
||||
* System dependencies
|
||||
|
||||
* Configuration
|
||||
|
||||
* Database creation
|
||||
|
||||
* Database initialization
|
||||
|
||||
* How to run the test suite
|
||||
|
||||
* Services (job queues, cache servers, search engines, etc.)
|
||||
|
||||
* Deployment instructions
|
||||
|
||||
* ...
|
||||
|
||||
|
||||
Please feel free to use a different markup language if you do not plan to run
|
||||
<tt>rake doc:app</tt>.
|
||||
5
app/controllers/sub_categories_controller.rb
Normal file
5
app/controllers/sub_categories_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class SubCategoriesController < ApplicationController
|
||||
active_scaffold :"sub_category" do |conf|
|
||||
conf.columns = [:name]
|
||||
end
|
||||
end
|
||||
2
app/helpers/sub_categories_helper.rb
Normal file
2
app/helpers/sub_categories_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module SubCategoriesHelper
|
||||
end
|
||||
@@ -1,2 +1,3 @@
|
||||
class Category < ActiveRecord::Base
|
||||
has_many :sub_categories
|
||||
end
|
||||
|
||||
3
app/models/sub_category.rb
Normal file
3
app/models/sub_category.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class SubCategory < ActiveRecord::Base
|
||||
belongs_to :category
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
Rails.application.routes.draw do
|
||||
resources :sub_categories do as_routes end
|
||||
resources :categories do as_routes end
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
49
test/controllers/sub_categories_controller_test.rb
Normal file
49
test/controllers/sub_categories_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SubCategoriesControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@sub_category = sub_categories(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:sub_categories)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create sub_category" do
|
||||
assert_difference('SubCategory.count') do
|
||||
post :create, sub_category: { category_id: @sub_category.category_id, name: @sub_category.name }
|
||||
end
|
||||
|
||||
assert_redirected_to sub_category_path(assigns(:sub_category))
|
||||
end
|
||||
|
||||
test "should show sub_category" do
|
||||
get :show, id: @sub_category
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @sub_category
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update sub_category" do
|
||||
patch :update, id: @sub_category, sub_category: { category_id: @sub_category.category_id, name: @sub_category.name }
|
||||
assert_redirected_to sub_category_path(assigns(:sub_category))
|
||||
end
|
||||
|
||||
test "should destroy sub_category" do
|
||||
assert_difference('SubCategory.count', -1) do
|
||||
delete :destroy, id: @sub_category
|
||||
end
|
||||
|
||||
assert_redirected_to sub_categories_path
|
||||
end
|
||||
end
|
||||
9
test/fixtures/sub_categories.yml
vendored
Normal file
9
test/fixtures/sub_categories.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
category_id: 1
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
category_id: 1
|
||||
7
test/models/sub_category_test.rb
Normal file
7
test/models/sub_category_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SubCategoryTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user