navinshop 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +21 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/navinshop/application.js +13 -0
- data/app/assets/javascripts/navinshop/categories.js +2 -0
- data/app/assets/javascripts/navinshop/items.js +2 -0
- data/app/assets/stylesheets/navinshop/application.css +15 -0
- data/app/assets/stylesheets/navinshop/categories.css +4 -0
- data/app/assets/stylesheets/navinshop/items.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/navinshop/application_controller.rb +2 -0
- data/app/controllers/navinshop/categories_controller.rb +62 -0
- data/app/controllers/navinshop/items_controller.rb +63 -0
- data/app/helpers/navinshop/application_helper.rb +4 -0
- data/app/helpers/navinshop/categories_helper.rb +4 -0
- data/app/helpers/navinshop/items_helper.rb +4 -0
- data/app/models/navinshop/category.rb +5 -0
- data/app/models/navinshop/item.rb +7 -0
- data/app/uploaders/navinshop/item_image_uploader.rb +51 -0
- data/app/views/navinshop/categories/_form.html.erb +21 -0
- data/app/views/navinshop/categories/edit.html.erb +6 -0
- data/app/views/navinshop/categories/index.html.erb +25 -0
- data/app/views/navinshop/categories/new.html.erb +5 -0
- data/app/views/navinshop/categories/show.html.erb +26 -0
- data/app/views/navinshop/items/_form.html.erb +33 -0
- data/app/views/navinshop/items/edit.html.erb +6 -0
- data/app/views/navinshop/items/index.html.erb +31 -0
- data/app/views/navinshop/items/new.html.erb +5 -0
- data/app/views/navinshop/items/show.html.erb +24 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20140517051602_create_navinshop_categories.rb +9 -0
- data/db/migrate/20140517051719_create_navinshop_items.rb +12 -0
- data/lib/navinshop/engine.rb +6 -0
- data/lib/navinshop/version.rb +3 -0
- data/lib/navinshop.rb +4 -0
- data/lib/tasks/navinshop_tasks.rake +4 -0
- data/test/controllers/navinshop/categories_controller_test.rb +51 -0
- data/test/controllers/navinshop/items_controller_test.rb +51 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +83 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +31 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +1258 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/uploads/navinshop/item/image/1/facebook_256.png +0 -0
- data/test/dummy/public/uploads/navinshop/item/image/1/thumb_facebook_256.png +0 -0
- data/test/dummy/public/uploads/navinshop/item/image/2/thumb_twitter_256.png +0 -0
- data/test/dummy/public/uploads/navinshop/item/image/2/twitter_256.png +0 -0
- data/test/dummy/public/uploads/navinshop/item/image/3/github_256.png +0 -0
- data/test/dummy/public/uploads/navinshop/item/image/3/thumb_github_256.png +0 -0
- data/test/dummy/public/uploads/navinshop/item/image/4/QSWRH___13_____.jpg +0 -0
- data/test/dummy/public/uploads/navinshop/item/image/4/thumb_QSWRH___13_____.jpg +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/fixtures/navinshop/categories.yml +7 -0
- data/test/fixtures/navinshop/items.yml +13 -0
- data/test/helpers/navinshop/categories_helper_test.rb +6 -0
- data/test/helpers/navinshop/items_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/navinshop/category_test.rb +9 -0
- data/test/models/navinshop/item_test.rb +9 -0
- data/test/navinshop_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +258 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b1aef8198322d31b67fab9c9e9da16149e1f7f1d
|
4
|
+
data.tar.gz: c8bd8808bd9b0895aab5b307f545a404dbe0dd22
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e9cdc1762bd529d693ebec4c06c472a8a7abffdbebbe70cf7271e40befbade9fcf3acbbf882ac984325c32ffd7fc8479e920fa6c97c97cbfcef0a6169f59e95
|
7
|
+
data.tar.gz: 7b8aae4b867715132c648459917e5e7d99ba5695e760a11b285152a3664a3389574613320d474e9716113ddf6a23e92c19ba3f4d23d2dc5ce15ad33769ba15f1
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
save this folder any where and create your blog
|
2
|
+
in gemfile of your blog add the gem name and gemspec path
|
3
|
+
for example if you this navinshop is in Desktop then the synatax is
|
4
|
+
/home/navin/Desktop/navinshop
|
5
|
+
|
6
|
+
then to install navinshop in your application run
|
7
|
+
rake navinshop:install:migrations
|
8
|
+
|
9
|
+
then run rake db:migrate to create database
|
10
|
+
|
11
|
+
then at routes.rb paste the following line
|
12
|
+
mount Navinshop::Engine => "shop"
|
13
|
+
|
14
|
+
now the navinshop is installed in your application and ready to go
|
15
|
+
you can find the navinshop ecart solution in
|
16
|
+
http://localhost:3000/shop/categories
|
17
|
+
in this route
|
18
|
+
|
19
|
+
|
20
|
+
you can create new category and new items under any category and also you can customize as well
|
21
|
+
|
data/Rakefile
ADDED
@@ -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 = 'Navinshop'
|
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,15 @@
|
|
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 bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_dependency "navinshop/application_controller"
|
2
|
+
|
3
|
+
module Navinshop
|
4
|
+
class CategoriesController < ApplicationController
|
5
|
+
before_action :set_category, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /categories
|
8
|
+
def index
|
9
|
+
@categories = Category.all
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /categories/1
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /categories/new
|
17
|
+
def new
|
18
|
+
@category = Category.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /categories/1/edit
|
22
|
+
def edit
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /categories
|
26
|
+
def create
|
27
|
+
@category = Category.new(category_params)
|
28
|
+
|
29
|
+
if @category.save
|
30
|
+
redirect_to @category, notice: 'Category was successfully created.'
|
31
|
+
else
|
32
|
+
render :new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# PATCH/PUT /categories/1
|
37
|
+
def update
|
38
|
+
if @category.update(category_params)
|
39
|
+
redirect_to @category, notice: 'Category was successfully updated.'
|
40
|
+
else
|
41
|
+
render :edit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# DELETE /categories/1
|
46
|
+
def destroy
|
47
|
+
@category.destroy
|
48
|
+
redirect_to categories_url, notice: 'Category was successfully destroyed.'
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
53
|
+
def set_category
|
54
|
+
@category = Category.find(params[:id])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
58
|
+
def category_params
|
59
|
+
params.require(:category).permit(:title)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_dependency "navinshop/application_controller"
|
2
|
+
|
3
|
+
module Navinshop
|
4
|
+
class ItemsController < ApplicationController
|
5
|
+
before_action :set_item, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /items
|
8
|
+
def index
|
9
|
+
@items = Item.all
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /items/1
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /items/new
|
17
|
+
def new
|
18
|
+
@item = Item.new
|
19
|
+
@item.category_id=params[:category_id]
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET /items/1/edit
|
23
|
+
def edit
|
24
|
+
end
|
25
|
+
|
26
|
+
# POST /items
|
27
|
+
def create
|
28
|
+
@item = Item.new(item_params)
|
29
|
+
|
30
|
+
if @item.save
|
31
|
+
redirect_to @item, notice: 'Item was successfully created.'
|
32
|
+
else
|
33
|
+
render :new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# PATCH/PUT /items/1
|
38
|
+
def update
|
39
|
+
if @item.update(item_params)
|
40
|
+
redirect_to @item, notice: 'Item was successfully updated.'
|
41
|
+
else
|
42
|
+
render :edit
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# DELETE /items/1
|
47
|
+
def destroy
|
48
|
+
@item.destroy
|
49
|
+
redirect_to items_url, notice: 'Item was successfully destroyed.'
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
# Use callbacks to share common setup or constraints between actions.
|
54
|
+
def set_item
|
55
|
+
@item = Item.find(params[:id])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Only allow a trusted parameter "white list" through.
|
59
|
+
def item_params
|
60
|
+
params.require(:item).permit(:title, :text, :category_id, :image)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class ItemImageUploader < CarrierWave::Uploader::Base
|
4
|
+
|
5
|
+
# Include RMagick or MiniMagick support:
|
6
|
+
include CarrierWave::RMagick
|
7
|
+
# include CarrierWave::MiniMagick
|
8
|
+
|
9
|
+
# Choose what kind of storage to use for this uploader:
|
10
|
+
storage :file
|
11
|
+
# storage :fog
|
12
|
+
|
13
|
+
# Override the directory where uploaded files will be stored.
|
14
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
15
|
+
def store_dir
|
16
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
20
|
+
# def default_url
|
21
|
+
# # For Rails 3.1+ asset pipeline compatibility:
|
22
|
+
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
23
|
+
#
|
24
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
25
|
+
# end
|
26
|
+
|
27
|
+
# Process files as they are uploaded:
|
28
|
+
# process :scale => [200, 300]
|
29
|
+
#
|
30
|
+
# def scale(width, height)
|
31
|
+
# # do something
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Create different versions of your uploaded files:
|
35
|
+
version :thumb do
|
36
|
+
process :resize_to_limit => [200, 200]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
40
|
+
# For images you might use something like this:
|
41
|
+
# def extension_white_list
|
42
|
+
# %w(jpg jpeg gif png)
|
43
|
+
# end
|
44
|
+
|
45
|
+
# Override the filename of the uploaded files:
|
46
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
47
|
+
# def filename
|
48
|
+
# "something.jpg" if original_filename
|
49
|
+
# end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= form_for(@category) do |f| %>
|
2
|
+
<% if @category.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@category.errors.count, "error") %> prohibited this category from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @category.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :title %><br>
|
16
|
+
<%= f.text_field :title %>
|
17
|
+
</div>
|
18
|
+
<div class="actions">
|
19
|
+
<%= f.submit %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<h1>Listing categories</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th>Title</th>
|
7
|
+
<th colspan="3"></th>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
|
11
|
+
<tbody>
|
12
|
+
<% @categories.each do |category| %>
|
13
|
+
<tr>
|
14
|
+
<td><%= category.title %></td>
|
15
|
+
<td><%= link_to 'Show', category %></td>
|
16
|
+
<td><%= link_to 'Edit', edit_category_path(category) %></td>
|
17
|
+
<td><%= link_to 'Destroy', category, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<br>
|
24
|
+
|
25
|
+
<%= link_to 'New Category', new_category_path %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<p id="notice"><%= notice %></p>
|
3
|
+
<div class="span9">
|
4
|
+
<strong>Title:</strong>
|
5
|
+
<%= @category.title %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
|
9
|
+
<% @category.items.each do |item| %>
|
10
|
+
<div class="span2 navinshop-item">
|
11
|
+
<%= image_tag item.image_url(:thumb).to_s %>
|
12
|
+
<h3><%= item.title %></h3>
|
13
|
+
<p>
|
14
|
+
<%= truncate(item.text, length:00, omission: "...") %>
|
15
|
+
</p>
|
16
|
+
<p>
|
17
|
+
<%= link_to "view details", item_path(item), :class => "btn btn-default" %>
|
18
|
+
</p>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
21
|
+
<div class="span9">
|
22
|
+
<%= link_to 'Edit', edit_category_path(@category), :class => "btn btn-default" %>
|
23
|
+
<%= link_to 'Back', categories_path, :class => "btn btn-default" %>
|
24
|
+
<%= link_to 'New item', new_category_item_path(@category), :class => "btn btn-default" %>
|
25
|
+
</div>
|
26
|
+
</div>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= form_for(@item , :multipart => true) do |f| %>
|
2
|
+
<% if @item.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@item.errors.count, "error") %> prohibited this item from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @item.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :title %><br>
|
16
|
+
<%= f.text_field :title %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :text %><br>
|
20
|
+
<%= f.text_area :text %>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div class="field">
|
24
|
+
<%= f.label :image %><br>
|
25
|
+
<%= f.file_field :image %>
|
26
|
+
</div>
|
27
|
+
<div class="field">
|
28
|
+
<%= f.hidden_field :category_id %>
|
29
|
+
</div>
|
30
|
+
<div class="actions">
|
31
|
+
<%= f.submit %>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<h1>Listing items</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th>Title</th>
|
7
|
+
<th>Text</th>
|
8
|
+
<th>Category</th>
|
9
|
+
<th>Image</th>
|
10
|
+
<th colspan="3"></th>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
|
14
|
+
<tbody>
|
15
|
+
<% @items.each do |item| %>
|
16
|
+
<tr>
|
17
|
+
<td><%= item.title %></td>
|
18
|
+
<td><%= item.text %></td>
|
19
|
+
<td><%= item.category_id %></td>
|
20
|
+
<td><%= item.image %></td>
|
21
|
+
<td><%= link_to 'Show', item %></td>
|
22
|
+
<td><%= link_to 'Edit', edit_item_path(item) %></td>
|
23
|
+
<td><%= link_to 'Destroy', item, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<br>
|
30
|
+
|
31
|
+
<%= link_to 'New Item', new_item_path %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Title:</strong>
|
5
|
+
<%= @item.title %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>Text:</strong>
|
10
|
+
<%= @item.text %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<strong>Category:</strong>
|
15
|
+
<%= @item.category_id %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<strong>Image:</strong>
|
20
|
+
<%= @item.image %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<%= link_to 'Edit', edit_item_path(@item) %> |
|
24
|
+
<%= link_to 'Back', items_path %>
|
data/config/routes.rb
ADDED
data/lib/navinshop.rb
ADDED