initial commit
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
|||||||
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
#
|
||||||
|
# If you find yourself ignoring temporary files generated by your text editor
|
||||||
|
# or operating system, you probably want to add a global ignore instead:
|
||||||
|
# git config --global core.excludesfile ~/.gitignore_global
|
||||||
|
|
||||||
|
# Ignore bundler config
|
||||||
|
/.bundle
|
||||||
|
|
||||||
|
# Ignore the default SQLite database.
|
||||||
|
/db/*.sqlite3
|
||||||
|
|
||||||
|
# Ignore all logfiles and tempfiles.
|
||||||
|
/log/*.log
|
||||||
|
/tmp
|
||||||
|
.sass-cache/
|
||||||
|
*.swp
|
||||||
|
db/xapian_db
|
||||||
|
company_logo*
|
||||||
|
public/assets
|
||||||
|
public/javascripts
|
||||||
|
beanlog.log
|
||||||
|
routes.txt
|
||||||
|
public/system
|
||||||
|
vendor/cache
|
||||||
|
public/google*
|
||||||
|
replication_design.html
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
gem 'rails', '3.2.8'
|
||||||
|
|
||||||
|
# Bundle edge Rails instead:
|
||||||
|
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
||||||
|
|
||||||
|
# gem 'sqlite3'
|
||||||
|
|
||||||
|
|
||||||
|
# Gems used only for assets and not required
|
||||||
|
# in production environments by default.
|
||||||
|
group :assets do
|
||||||
|
gem 'sass-rails', '~> 3.2.3'
|
||||||
|
gem 'coffee-rails', '~> 3.2.1'
|
||||||
|
gem 'twitter-bootstrap-rails'
|
||||||
|
|
||||||
|
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||||
|
# gem 'therubyracer', :platforms => :ruby
|
||||||
|
|
||||||
|
gem 'uglifier', '>= 1.0.3'
|
||||||
|
end
|
||||||
|
|
||||||
|
gem 'jquery-rails'
|
||||||
|
gem 'haml-rails'
|
||||||
|
gem 'slim-rails'
|
||||||
|
|
||||||
|
gem 'couch_potato' , :git => 'git://github.com/bterkuile/couch_potato.git'
|
||||||
|
gem 'simply_stored' , :git => 'git://github.com/bterkuile/simply_stored.git'
|
||||||
|
gem 'devise', '2.0.4'
|
||||||
|
gem 'devise_simply_stored'
|
||||||
|
|
||||||
|
gem 'rqrcode-rails3'
|
||||||
|
gem 'mini_magick'
|
||||||
|
|
||||||
|
# To use ActiveModel has_secure_password
|
||||||
|
# gem 'bcrypt-ruby', '~> 3.0.0'
|
||||||
|
|
||||||
|
# To use Jbuilder templates for JSON
|
||||||
|
# gem 'jbuilder'
|
||||||
|
group :development do
|
||||||
|
gem 'pry'
|
||||||
|
gem 'rspec-rails'
|
||||||
|
gem 'thin'
|
||||||
|
end
|
||||||
|
|
||||||
|
group :test do
|
||||||
|
gem 'rspec-rails'
|
||||||
|
gem 'capybara'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Use unicorn as the app server
|
||||||
|
# gem 'unicorn'
|
||||||
|
|
||||||
|
# Deploy with Capistrano
|
||||||
|
# gem 'capistrano'
|
||||||
|
|
||||||
|
# To use debugger
|
||||||
|
# gem 'debugger'
|
||||||
+241
@@ -0,0 +1,241 @@
|
|||||||
|
GIT
|
||||||
|
remote: git://github.com/bterkuile/couch_potato.git
|
||||||
|
revision: ff7505c432cabfccb55cfa732a548d9449d8250c
|
||||||
|
specs:
|
||||||
|
couch_potato (0.7.0.pre.1)
|
||||||
|
activemodel
|
||||||
|
couchrest (>= 1.0.1)
|
||||||
|
json (~> 1.6.0)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/bterkuile/simply_stored.git
|
||||||
|
revision: ad8c6af0d845a8eb3d1caeb47ede1e607f94e854
|
||||||
|
specs:
|
||||||
|
simply_stored (1.0.0)
|
||||||
|
activesupport
|
||||||
|
couch_potato (>= 0.2.15)
|
||||||
|
rest-client (>= 1.4.2)
|
||||||
|
|
||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
actionmailer (3.2.8)
|
||||||
|
actionpack (= 3.2.8)
|
||||||
|
mail (~> 2.4.4)
|
||||||
|
actionpack (3.2.8)
|
||||||
|
activemodel (= 3.2.8)
|
||||||
|
activesupport (= 3.2.8)
|
||||||
|
builder (~> 3.0.0)
|
||||||
|
erubis (~> 2.7.0)
|
||||||
|
journey (~> 1.0.4)
|
||||||
|
rack (~> 1.4.0)
|
||||||
|
rack-cache (~> 1.2)
|
||||||
|
rack-test (~> 0.6.1)
|
||||||
|
sprockets (~> 2.1.3)
|
||||||
|
activemodel (3.2.8)
|
||||||
|
activesupport (= 3.2.8)
|
||||||
|
builder (~> 3.0.0)
|
||||||
|
activerecord (3.2.8)
|
||||||
|
activemodel (= 3.2.8)
|
||||||
|
activesupport (= 3.2.8)
|
||||||
|
arel (~> 3.0.2)
|
||||||
|
tzinfo (~> 0.3.29)
|
||||||
|
activeresource (3.2.8)
|
||||||
|
activemodel (= 3.2.8)
|
||||||
|
activesupport (= 3.2.8)
|
||||||
|
activesupport (3.2.8)
|
||||||
|
i18n (~> 0.6)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
addressable (2.3.2)
|
||||||
|
arel (3.0.2)
|
||||||
|
bcrypt-ruby (3.0.1)
|
||||||
|
builder (3.0.0)
|
||||||
|
capybara (1.1.2)
|
||||||
|
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.3.5)
|
||||||
|
ffi (~> 1.0, >= 1.0.6)
|
||||||
|
coderay (1.0.7)
|
||||||
|
coffee-rails (3.2.2)
|
||||||
|
coffee-script (>= 2.2.0)
|
||||||
|
railties (~> 3.2.0)
|
||||||
|
coffee-script (2.2.0)
|
||||||
|
coffee-script-source
|
||||||
|
execjs
|
||||||
|
coffee-script-source (1.3.3)
|
||||||
|
commonjs (0.2.6)
|
||||||
|
couchrest (1.1.3)
|
||||||
|
mime-types (~> 1.15)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
rest-client (~> 1.6.1)
|
||||||
|
daemons (1.1.9)
|
||||||
|
devise (2.0.4)
|
||||||
|
bcrypt-ruby (~> 3.0)
|
||||||
|
orm_adapter (~> 0.0.3)
|
||||||
|
railties (~> 3.1)
|
||||||
|
warden (~> 1.1.1)
|
||||||
|
devise_simply_stored (0.0.2)
|
||||||
|
devise
|
||||||
|
diff-lcs (1.1.3)
|
||||||
|
erubis (2.7.0)
|
||||||
|
eventmachine (0.12.10)
|
||||||
|
execjs (1.4.0)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
ffi (1.1.5)
|
||||||
|
haml (3.1.7)
|
||||||
|
haml-rails (0.3.4)
|
||||||
|
actionpack (~> 3.0)
|
||||||
|
activesupport (~> 3.0)
|
||||||
|
haml (~> 3.0)
|
||||||
|
railties (~> 3.0)
|
||||||
|
hike (1.2.1)
|
||||||
|
i18n (0.6.0)
|
||||||
|
journey (1.0.4)
|
||||||
|
jquery-rails (2.1.1)
|
||||||
|
railties (>= 3.1.0, < 5.0)
|
||||||
|
thor (~> 0.14)
|
||||||
|
json (1.6.7)
|
||||||
|
less (2.2.1)
|
||||||
|
commonjs (~> 0.2.6)
|
||||||
|
less-rails (2.2.3)
|
||||||
|
actionpack (>= 3.1)
|
||||||
|
less (~> 2.2.0)
|
||||||
|
libv8 (3.3.10.4)
|
||||||
|
libwebsocket (0.1.5)
|
||||||
|
addressable
|
||||||
|
mail (2.4.4)
|
||||||
|
i18n (>= 0.4.0)
|
||||||
|
mime-types (~> 1.16)
|
||||||
|
treetop (~> 1.4.8)
|
||||||
|
method_source (0.8)
|
||||||
|
mime-types (1.19)
|
||||||
|
mini_magick (3.4)
|
||||||
|
subexec (~> 0.2.1)
|
||||||
|
multi_json (1.3.6)
|
||||||
|
nokogiri (1.5.5)
|
||||||
|
orm_adapter (0.0.7)
|
||||||
|
polyglot (0.3.3)
|
||||||
|
pry (0.9.10)
|
||||||
|
coderay (~> 1.0.5)
|
||||||
|
method_source (~> 0.8)
|
||||||
|
slop (~> 3.3.1)
|
||||||
|
rack (1.4.1)
|
||||||
|
rack-cache (1.2)
|
||||||
|
rack (>= 0.4)
|
||||||
|
rack-ssl (1.3.2)
|
||||||
|
rack
|
||||||
|
rack-test (0.6.1)
|
||||||
|
rack (>= 1.0)
|
||||||
|
rails (3.2.8)
|
||||||
|
actionmailer (= 3.2.8)
|
||||||
|
actionpack (= 3.2.8)
|
||||||
|
activerecord (= 3.2.8)
|
||||||
|
activeresource (= 3.2.8)
|
||||||
|
activesupport (= 3.2.8)
|
||||||
|
bundler (~> 1.0)
|
||||||
|
railties (= 3.2.8)
|
||||||
|
railties (3.2.8)
|
||||||
|
actionpack (= 3.2.8)
|
||||||
|
activesupport (= 3.2.8)
|
||||||
|
rack-ssl (~> 1.3.2)
|
||||||
|
rake (>= 0.8.7)
|
||||||
|
rdoc (~> 3.4)
|
||||||
|
thor (>= 0.14.6, < 2.0)
|
||||||
|
rake (0.9.2.2)
|
||||||
|
rdoc (3.12)
|
||||||
|
json (~> 1.4)
|
||||||
|
rest-client (1.6.7)
|
||||||
|
mime-types (>= 1.16)
|
||||||
|
rqrcode (0.4.2)
|
||||||
|
rqrcode-rails3 (0.1.5)
|
||||||
|
rqrcode (>= 0.4.2)
|
||||||
|
rspec (2.11.0)
|
||||||
|
rspec-core (~> 2.11.0)
|
||||||
|
rspec-expectations (~> 2.11.0)
|
||||||
|
rspec-mocks (~> 2.11.0)
|
||||||
|
rspec-core (2.11.1)
|
||||||
|
rspec-expectations (2.11.2)
|
||||||
|
diff-lcs (~> 1.1.3)
|
||||||
|
rspec-mocks (2.11.2)
|
||||||
|
rspec-rails (2.11.0)
|
||||||
|
actionpack (>= 3.0)
|
||||||
|
activesupport (>= 3.0)
|
||||||
|
railties (>= 3.0)
|
||||||
|
rspec (~> 2.11.0)
|
||||||
|
rubyzip (0.9.9)
|
||||||
|
sass (3.2.1)
|
||||||
|
sass-rails (3.2.5)
|
||||||
|
railties (~> 3.2.0)
|
||||||
|
sass (>= 3.1.10)
|
||||||
|
tilt (~> 1.3)
|
||||||
|
selenium-webdriver (2.25.0)
|
||||||
|
childprocess (>= 0.2.5)
|
||||||
|
libwebsocket (~> 0.1.3)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
rubyzip
|
||||||
|
slim (1.2.2)
|
||||||
|
temple (~> 0.4.0)
|
||||||
|
tilt (~> 1.3.3)
|
||||||
|
slim-rails (1.0.3)
|
||||||
|
actionpack (~> 3.0)
|
||||||
|
activesupport (~> 3.0)
|
||||||
|
railties (~> 3.0)
|
||||||
|
slim (~> 1.0)
|
||||||
|
slop (3.3.2)
|
||||||
|
sprockets (2.1.3)
|
||||||
|
hike (~> 1.2)
|
||||||
|
rack (~> 1.0)
|
||||||
|
tilt (~> 1.1, != 1.3.0)
|
||||||
|
subexec (0.2.2)
|
||||||
|
temple (0.4.0)
|
||||||
|
therubyracer (0.10.1)
|
||||||
|
libv8 (~> 3.3.10)
|
||||||
|
thin (1.4.1)
|
||||||
|
daemons (>= 1.0.9)
|
||||||
|
eventmachine (>= 0.12.6)
|
||||||
|
rack (>= 1.0.0)
|
||||||
|
thor (0.16.0)
|
||||||
|
tilt (1.3.3)
|
||||||
|
treetop (1.4.10)
|
||||||
|
polyglot
|
||||||
|
polyglot (>= 0.3.1)
|
||||||
|
twitter-bootstrap-rails (2.1.1)
|
||||||
|
actionpack (>= 3.1)
|
||||||
|
less-rails (~> 2.2.2)
|
||||||
|
railties (>= 3.1)
|
||||||
|
therubyracer (= 0.10.1)
|
||||||
|
tzinfo (0.3.33)
|
||||||
|
uglifier (1.2.7)
|
||||||
|
execjs (>= 0.3.0)
|
||||||
|
multi_json (~> 1.3)
|
||||||
|
warden (1.1.1)
|
||||||
|
rack (>= 1.0)
|
||||||
|
xpath (0.1.4)
|
||||||
|
nokogiri (~> 1.3)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
ruby
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
capybara
|
||||||
|
coffee-rails (~> 3.2.1)
|
||||||
|
couch_potato!
|
||||||
|
devise (= 2.0.4)
|
||||||
|
devise_simply_stored
|
||||||
|
haml-rails
|
||||||
|
jquery-rails
|
||||||
|
mini_magick
|
||||||
|
pry
|
||||||
|
rails (= 3.2.8)
|
||||||
|
rqrcode-rails3
|
||||||
|
rspec-rails
|
||||||
|
sass-rails (~> 3.2.3)
|
||||||
|
simply_stored!
|
||||||
|
slim-rails
|
||||||
|
thin
|
||||||
|
twitter-bootstrap-rails
|
||||||
|
uglifier (>= 1.0.3)
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+261
@@ -0,0 +1,261 @@
|
|||||||
|
== Welcome to Rails
|
||||||
|
|
||||||
|
Rails is a web-application framework that includes everything needed to create
|
||||||
|
database-backed web applications according to the Model-View-Control pattern.
|
||||||
|
|
||||||
|
This pattern splits the view (also called the presentation) into "dumb"
|
||||||
|
templates that are primarily responsible for inserting pre-built data in between
|
||||||
|
HTML tags. The model contains the "smart" domain objects (such as Account,
|
||||||
|
Product, Person, Post) that holds all the business logic and knows how to
|
||||||
|
persist themselves to a database. The controller handles the incoming requests
|
||||||
|
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
||||||
|
and directing data to the view.
|
||||||
|
|
||||||
|
In Rails, the model is handled by what's called an object-relational mapping
|
||||||
|
layer entitled Active Record. This layer allows you to present the data from
|
||||||
|
database rows as objects and embellish these data objects with business logic
|
||||||
|
methods. You can read more about Active Record in
|
||||||
|
link:files/vendor/rails/activerecord/README.html.
|
||||||
|
|
||||||
|
The controller and view are handled by the Action Pack, which handles both
|
||||||
|
layers by its two parts: Action View and Action Controller. These two layers
|
||||||
|
are bundled in a single package due to their heavy interdependence. This is
|
||||||
|
unlike the relationship between the Active Record and Action Pack that is much
|
||||||
|
more separate. Each of these packages can be used independently outside of
|
||||||
|
Rails. You can read more about Action Pack in
|
||||||
|
link:files/vendor/rails/actionpack/README.html.
|
||||||
|
|
||||||
|
|
||||||
|
== Getting Started
|
||||||
|
|
||||||
|
1. At the command prompt, create a new Rails application:
|
||||||
|
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
||||||
|
|
||||||
|
2. Change directory to <tt>myapp</tt> and start the web server:
|
||||||
|
<tt>cd myapp; rails server</tt> (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/
|
||||||
|
|
||||||
|
|
||||||
|
== Debugging Rails
|
||||||
|
|
||||||
|
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
||||||
|
will help you debug it and get it back on the rails.
|
||||||
|
|
||||||
|
First area to check is the application log files. Have "tail -f" commands
|
||||||
|
running on the server.log and development.log. Rails will automatically display
|
||||||
|
debugging and runtime information to these files. Debugging info will also be
|
||||||
|
shown in the browser on requests from 127.0.0.1.
|
||||||
|
|
||||||
|
You can also log your own messages directly into the log file from your code
|
||||||
|
using the Ruby logger class from inside your controllers. Example:
|
||||||
|
|
||||||
|
class WeblogController < ActionController::Base
|
||||||
|
def destroy
|
||||||
|
@weblog = Weblog.find(params[:id])
|
||||||
|
@weblog.destroy
|
||||||
|
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
The result will be a message in your log file along the lines of:
|
||||||
|
|
||||||
|
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
||||||
|
|
||||||
|
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
||||||
|
|
||||||
|
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
||||||
|
several books available online as well:
|
||||||
|
|
||||||
|
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
||||||
|
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
||||||
|
|
||||||
|
These two books will bring you up to speed on the Ruby language and also on
|
||||||
|
programming in general.
|
||||||
|
|
||||||
|
|
||||||
|
== Debugger
|
||||||
|
|
||||||
|
Debugger support is available through the debugger command when you start your
|
||||||
|
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
||||||
|
execution at any point in the code, investigate and change the model, and then,
|
||||||
|
resume execution! You need to install ruby-debug to run the server in debugging
|
||||||
|
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
||||||
|
|
||||||
|
class WeblogController < ActionController::Base
|
||||||
|
def index
|
||||||
|
@posts = Post.all
|
||||||
|
debugger
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
So the controller will accept the action, run the first line, then present you
|
||||||
|
with a IRB prompt in the server window. Here you can do things like:
|
||||||
|
|
||||||
|
>> @posts.inspect
|
||||||
|
=> "[#<Post:0x14a6be8
|
||||||
|
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
||||||
|
#<Post:0x14a6620
|
||||||
|
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
||||||
|
>> @posts.first.title = "hello from a debugger"
|
||||||
|
=> "hello from a debugger"
|
||||||
|
|
||||||
|
...and even better, you can examine how your runtime objects actually work:
|
||||||
|
|
||||||
|
>> f = @posts.first
|
||||||
|
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
||||||
|
>> f.
|
||||||
|
Display all 152 possibilities? (y or n)
|
||||||
|
|
||||||
|
Finally, when you're ready to resume execution, you can enter "cont".
|
||||||
|
|
||||||
|
|
||||||
|
== Console
|
||||||
|
|
||||||
|
The console is a Ruby shell, which allows you to interact with your
|
||||||
|
application's domain model. Here you'll have all parts of the application
|
||||||
|
configured, just like it is when the application is running. You can inspect
|
||||||
|
domain models, change values, and save to the database. Starting the script
|
||||||
|
without arguments will launch it in the development environment.
|
||||||
|
|
||||||
|
To start the console, run <tt>rails console</tt> from the application
|
||||||
|
directory.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
||||||
|
made to the database.
|
||||||
|
* Passing an environment name as an argument will load the corresponding
|
||||||
|
environment. Example: <tt>rails console production</tt>.
|
||||||
|
|
||||||
|
To reload your controllers and models after launching the console run
|
||||||
|
<tt>reload!</tt>
|
||||||
|
|
||||||
|
More information about irb can be found at:
|
||||||
|
link:http://www.rubycentral.org/pickaxe/irb.html
|
||||||
|
|
||||||
|
|
||||||
|
== dbconsole
|
||||||
|
|
||||||
|
You can go to the command line of your database directly through <tt>rails
|
||||||
|
dbconsole</tt>. You would be connected to the database with the credentials
|
||||||
|
defined in database.yml. Starting the script without arguments will connect you
|
||||||
|
to the development database. Passing an argument will connect you to a different
|
||||||
|
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
||||||
|
PostgreSQL and SQLite 3.
|
||||||
|
|
||||||
|
== Description of Contents
|
||||||
|
|
||||||
|
The default directory structure of a generated Ruby on Rails application:
|
||||||
|
|
||||||
|
|-- app
|
||||||
|
| |-- assets
|
||||||
|
| |-- images
|
||||||
|
| |-- javascripts
|
||||||
|
| `-- stylesheets
|
||||||
|
| |-- controllers
|
||||||
|
| |-- helpers
|
||||||
|
| |-- mailers
|
||||||
|
| |-- models
|
||||||
|
| `-- views
|
||||||
|
| `-- layouts
|
||||||
|
|-- config
|
||||||
|
| |-- environments
|
||||||
|
| |-- initializers
|
||||||
|
| `-- locales
|
||||||
|
|-- db
|
||||||
|
|-- doc
|
||||||
|
|-- lib
|
||||||
|
| `-- tasks
|
||||||
|
|-- log
|
||||||
|
|-- public
|
||||||
|
|-- script
|
||||||
|
|-- test
|
||||||
|
| |-- fixtures
|
||||||
|
| |-- functional
|
||||||
|
| |-- integration
|
||||||
|
| |-- performance
|
||||||
|
| `-- unit
|
||||||
|
|-- tmp
|
||||||
|
| |-- cache
|
||||||
|
| |-- pids
|
||||||
|
| |-- 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
|
||||||
|
ApplicationController which itself descends from ActionController::Base.
|
||||||
|
|
||||||
|
app/models
|
||||||
|
Holds models that should be named like post.rb. Models descend from
|
||||||
|
ActiveRecord::Base by default.
|
||||||
|
|
||||||
|
app/views
|
||||||
|
Holds the template files for the view that should be named like
|
||||||
|
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
||||||
|
eRuby syntax by default.
|
||||||
|
|
||||||
|
app/views/layouts
|
||||||
|
Holds the template files for layouts to be used with views. This models the
|
||||||
|
common header/footer method of wrapping views. In your views, define a layout
|
||||||
|
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
||||||
|
Inside default.html.erb, call <% yield %> to render the view using this
|
||||||
|
layout.
|
||||||
|
|
||||||
|
app/helpers
|
||||||
|
Holds view helpers that should be named like weblogs_helper.rb. These are
|
||||||
|
generated for you automatically when using generators for controllers.
|
||||||
|
Helpers can be used to wrap functionality for your views into methods.
|
||||||
|
|
||||||
|
config
|
||||||
|
Configuration files for the Rails environment, the routing map, the database,
|
||||||
|
and other dependencies.
|
||||||
|
|
||||||
|
db
|
||||||
|
Contains the database schema in schema.rb. db/migrate contains all the
|
||||||
|
sequence of Migrations for your schema.
|
||||||
|
|
||||||
|
doc
|
||||||
|
This directory is where your application documentation will be stored when
|
||||||
|
generated using <tt>rake doc:app</tt>
|
||||||
|
|
||||||
|
lib
|
||||||
|
Application specific libraries. Basically, any kind of custom code that
|
||||||
|
doesn't belong under controllers, models, or helpers. This directory is in
|
||||||
|
the load path.
|
||||||
|
|
||||||
|
public
|
||||||
|
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.
|
||||||
|
|
||||||
|
script
|
||||||
|
Helper scripts for automation and generation.
|
||||||
|
|
||||||
|
test
|
||||||
|
Unit and functional tests along with fixtures. When using the rails generate
|
||||||
|
command, template test files will be generated for you and placed in this
|
||||||
|
directory.
|
||||||
|
|
||||||
|
vendor
|
||||||
|
External libraries that the application depends on. Also includes the plugins
|
||||||
|
subdirectory. If the app has frozen rails, those gems also go here, under
|
||||||
|
vendor/rails/. This directory is in the load path.
|
||||||
@@ -0,0 +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__)
|
||||||
|
|
||||||
|
Qrammer::Application.load_tasks
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
@@ -0,0 +1,16 @@
|
|||||||
|
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||||
|
// listed below.
|
||||||
|
//
|
||||||
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||||
|
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||||
|
//
|
||||||
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||||
|
// the compiled file.
|
||||||
|
//
|
||||||
|
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||||
|
// GO AFTER THE REQUIRES BELOW.
|
||||||
|
//
|
||||||
|
//= require jquery
|
||||||
|
//= require jquery_ujs
|
||||||
|
//= require twitter/bootstrap
|
||||||
|
//= require_tree .
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
jQuery ->
|
||||||
|
$("a[rel=popover]").popover()
|
||||||
|
$(".tooltip").tooltip()
|
||||||
|
$("a[rel=tooltip]").tooltip()
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||||
|
* listed below.
|
||||||
|
*
|
||||||
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||||
|
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||||
|
*
|
||||||
|
* 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 .
|
||||||
|
*/
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
@import "twitter/bootstrap/bootstrap";
|
||||||
|
body {
|
||||||
|
padding-top: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@import "twitter/bootstrap/responsive";
|
||||||
|
|
||||||
|
// Set the correct sprite paths
|
||||||
|
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
|
||||||
|
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
|
||||||
|
|
||||||
|
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
|
||||||
|
// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not
|
||||||
|
// have the proper paths. So for now we use the absolute path.
|
||||||
|
@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot';
|
||||||
|
@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff';
|
||||||
|
@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf';
|
||||||
|
@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg';
|
||||||
|
|
||||||
|
// Font Awesome
|
||||||
|
@import "fontawesome";
|
||||||
|
|
||||||
|
// Your custom LESS stylesheets goes here
|
||||||
|
//
|
||||||
|
// Since bootstrap was imported above you have access to its mixins which
|
||||||
|
// you may use and inherit here
|
||||||
|
//
|
||||||
|
// If you'd like to override bootstrap's own variables, you can do so here as well
|
||||||
|
// See http://twitter.github.com/bootstrap/less.html for their names and documentation
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
// @linkColor: #ff0000;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the Users controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class ApplicationController < ActionController::Base
|
||||||
|
protect_from_forgery
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def active_list
|
||||||
|
List.find(session[:list_id])
|
||||||
|
end
|
||||||
|
helper_method :active_list
|
||||||
|
end
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
class DashboardController < ApplicationController
|
||||||
|
|
||||||
|
def home
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Testing action
|
||||||
|
def select_qrcode
|
||||||
|
@tables = Table.all
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_list
|
||||||
|
@table = Table.find(params[:table_id])
|
||||||
|
if @table.occupied?
|
||||||
|
redirect_to root_path, alert: t('table.is_occupied')
|
||||||
|
else
|
||||||
|
@list = List.new(table: @table)
|
||||||
|
#@list.add_user(current_user)
|
||||||
|
@list.save
|
||||||
|
session[:list_id] = @list.id
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_products
|
||||||
|
@supplier = Supplier.first
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
class ListsController < ApplicationController
|
||||||
|
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
|
||||||
|
# GET /lists
|
||||||
|
# GET /lists.json
|
||||||
|
def index
|
||||||
|
@lists = List.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @lists }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /lists/1
|
||||||
|
# GET /lists/1.json
|
||||||
|
def show
|
||||||
|
@list = List.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @list }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /lists/new
|
||||||
|
# GET /lists/new.json
|
||||||
|
def new
|
||||||
|
@list = List.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @list }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /lists/1/edit
|
||||||
|
def edit
|
||||||
|
@list = List.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /lists
|
||||||
|
# POST /lists.json
|
||||||
|
def create
|
||||||
|
@list = List.new(params[:list])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @list.save
|
||||||
|
format.html { redirect_to @list, notice: t('action.create.successfull', model: List.model_name.human) }
|
||||||
|
format.json { render json: @list, status: :created, location: @list }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @list.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /lists/1
|
||||||
|
# PUT /lists/1.json
|
||||||
|
def update
|
||||||
|
@list = List.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @list.update_attributes(params[:list])
|
||||||
|
format.html { redirect_to @list, notice: t('action.update.successfull', model: List.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @list.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /lists/1
|
||||||
|
# DELETE /lists/1.json
|
||||||
|
def destroy
|
||||||
|
@list = List.find(params[:id])
|
||||||
|
@list.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to lists_url, notice: t('action.destroy.successfull', model: List.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_relation_options
|
||||||
|
@tables = Table.all
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
class ProductCategoriesController < ApplicationController
|
||||||
|
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
|
||||||
|
# GET /product_categories
|
||||||
|
# GET /product_categories.json
|
||||||
|
def index
|
||||||
|
@product_categories = ProductCategory.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @product_categories }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /product_categories/1
|
||||||
|
# GET /product_categories/1.json
|
||||||
|
def show
|
||||||
|
@product_category = ProductCategory.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @product_category }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /product_categories/new
|
||||||
|
# GET /product_categories/new.json
|
||||||
|
def new
|
||||||
|
@product_category = ProductCategory.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @product_category }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /product_categories/1/edit
|
||||||
|
def edit
|
||||||
|
@product_category = ProductCategory.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /product_categories
|
||||||
|
# POST /product_categories.json
|
||||||
|
def create
|
||||||
|
@product_category = ProductCategory.new(params[:product_category])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @product_category.save
|
||||||
|
format.html { redirect_to @product_category, notice: t('action.create.successfull', model: ProductCategory.model_name.human) }
|
||||||
|
format.json { render json: @product_category, status: :created, location: @product_category }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @product_category.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /product_categories/1
|
||||||
|
# PUT /product_categories/1.json
|
||||||
|
def update
|
||||||
|
@product_category = ProductCategory.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @product_category.update_attributes(params[:product_category])
|
||||||
|
format.html { redirect_to @product_category, notice: t('action.update.successfull', model: ProductCategory.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @product_category.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /product_categories/1
|
||||||
|
# DELETE /product_categories/1.json
|
||||||
|
def destroy
|
||||||
|
@product_category = ProductCategory.find(params[:id])
|
||||||
|
@product_category.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to product_categories_url, notice: t('action.destroy.successfull', model: ProductCategory.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /product_categories/qrcode
|
||||||
|
# GET /product_categories/qrcode.png
|
||||||
|
# GET /product_categories/qrcode.svg
|
||||||
|
def qrcode
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.svg { render :qrcode => request.url, :level => :l, :unit => 10 }
|
||||||
|
format.png { render qrcode: request.url }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_relation_options
|
||||||
|
@suppliers = Supplier.all
|
||||||
|
@lists = List.all
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
class ProductsController < ApplicationController
|
||||||
|
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
|
||||||
|
# GET /products
|
||||||
|
# GET /products.json
|
||||||
|
def index
|
||||||
|
@products = Product.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @products }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /products/1
|
||||||
|
# GET /products/1.json
|
||||||
|
def show
|
||||||
|
@product = Product.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @product }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /products/new
|
||||||
|
# GET /products/new.json
|
||||||
|
def new
|
||||||
|
@product = Product.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @product }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /products/1/edit
|
||||||
|
def edit
|
||||||
|
@product = Product.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /products
|
||||||
|
# POST /products.json
|
||||||
|
def create
|
||||||
|
@product = Product.new(params[:product])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @product.save
|
||||||
|
format.html { redirect_to @product, notice: t('action.create.successfull', model: Product.model_name.human) }
|
||||||
|
format.json { render json: @product, status: :created, location: @product }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @product.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /products/1
|
||||||
|
# PUT /products/1.json
|
||||||
|
def update
|
||||||
|
@product = Product.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @product.update_attributes(params[:product])
|
||||||
|
format.html { redirect_to @product, notice: t('action.update.successfull', model: Product.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @product.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /products/1
|
||||||
|
# DELETE /products/1.json
|
||||||
|
def destroy
|
||||||
|
@product = Product.find(params[:id])
|
||||||
|
@product.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to products_url, notice: t('action.destroy.successfull', model: Product.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_relation_options
|
||||||
|
@suppliers = Supplier.all
|
||||||
|
@product_categories = ProductCategory.all
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
class SuppliersController < ApplicationController
|
||||||
|
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
|
||||||
|
# GET /suppliers
|
||||||
|
# GET /suppliers.json
|
||||||
|
def index
|
||||||
|
@suppliers = Supplier.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @suppliers }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /suppliers/1
|
||||||
|
# GET /suppliers/1.json
|
||||||
|
def show
|
||||||
|
@supplier = Supplier.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @supplier }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /suppliers/new
|
||||||
|
# GET /suppliers/new.json
|
||||||
|
def new
|
||||||
|
@supplier = Supplier.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @supplier }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /suppliers/1/edit
|
||||||
|
def edit
|
||||||
|
@supplier = Supplier.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /suppliers
|
||||||
|
# POST /suppliers.json
|
||||||
|
def create
|
||||||
|
@supplier = Supplier.new(params[:supplier])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @supplier.save
|
||||||
|
format.html { redirect_to @supplier, notice: t('action.create.successfull', model: Supplier.model_name.human) }
|
||||||
|
format.json { render json: @supplier, status: :created, location: @supplier }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @supplier.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /suppliers/1
|
||||||
|
# PUT /suppliers/1.json
|
||||||
|
def update
|
||||||
|
@supplier = Supplier.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @supplier.update_attributes(params[:supplier])
|
||||||
|
format.html { redirect_to @supplier, notice: t('action.update.successfull', model: Supplier.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @supplier.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /suppliers/1
|
||||||
|
# DELETE /suppliers/1.json
|
||||||
|
def destroy
|
||||||
|
@supplier = Supplier.find(params[:id])
|
||||||
|
@supplier.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to suppliers_url, notice: t('action.destroy.successfull', model: Supplier.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /suppliers/1/product_list
|
||||||
|
# GET /suppliers/1/product_list.json
|
||||||
|
def product_list
|
||||||
|
@supplier = Supplier.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json do
|
||||||
|
products = @supplier.products
|
||||||
|
products.include_relation(:product_categories)
|
||||||
|
h = products.inject({}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
|
||||||
|
render json: h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_relation_options
|
||||||
|
@suppliers = Supplier.all
|
||||||
|
@lists = List.all
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
class TablesController < ApplicationController
|
||||||
|
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
|
||||||
|
# GET /tables
|
||||||
|
# GET /tables.json
|
||||||
|
def index
|
||||||
|
@tables = Table.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @tables }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /tables/1
|
||||||
|
# GET /tables/1.json
|
||||||
|
def show
|
||||||
|
@table = Table.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @table }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /tables/new
|
||||||
|
# GET /tables/new.json
|
||||||
|
def new
|
||||||
|
@table = Table.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @table }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /tables/1/edit
|
||||||
|
def edit
|
||||||
|
@table = Table.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /tables
|
||||||
|
# POST /tables.json
|
||||||
|
def create
|
||||||
|
@table = Table.new(params[:table])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @table.save
|
||||||
|
format.html { redirect_to @table, notice: t('action.create.successfull', model: Table.model_name.human) }
|
||||||
|
format.json { render json: @table, status: :created, location: @table }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @table.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /tables/1
|
||||||
|
# PUT /tables/1.json
|
||||||
|
def update
|
||||||
|
@table = Table.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @table.update_attributes(params[:table])
|
||||||
|
format.html { redirect_to @table, notice: t('action.update.successfull', model: Table.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @table.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /tables/1
|
||||||
|
# DELETE /tables/1.json
|
||||||
|
def destroy
|
||||||
|
@table = Table.find(params[:id])
|
||||||
|
@table.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to tables_url, notice: t('action.destroy.successfull', model: Table.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /tables/qrcode
|
||||||
|
# GET /tables/qrcode.png
|
||||||
|
# GET /tables/qrcode.svg
|
||||||
|
def qrcode
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.svg { render :qrcode => request.url, :level => :l, :unit => 10 }
|
||||||
|
format.png { render qrcode: request.url }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_relation_options
|
||||||
|
@suppliers = Supplier.all
|
||||||
|
@lists = List.all
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
class UsersController < ApplicationController
|
||||||
|
# GET /users
|
||||||
|
# GET /users.json
|
||||||
|
def index
|
||||||
|
@users = User.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @users }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /users/1
|
||||||
|
# GET /users/1.json
|
||||||
|
def show
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @user }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /users/new
|
||||||
|
# GET /users/new.json
|
||||||
|
def new
|
||||||
|
@user = User.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @user }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /users/1/edit
|
||||||
|
def edit
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /users
|
||||||
|
# POST /users.json
|
||||||
|
def create
|
||||||
|
@user = User.new(params[:user])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @user.save
|
||||||
|
format.html { redirect_to @user, notice: t('action.create.successfull', model: User.model_name.human) }
|
||||||
|
format.json { render json: @user, status: :created, location: @user }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /users/1
|
||||||
|
# PUT /users/1.json
|
||||||
|
def update
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @user.update_attributes(params[:user])
|
||||||
|
format.html { redirect_to @user, notice: t('action.update.successfull', model: User.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /users/1
|
||||||
|
# DELETE /users/1.json
|
||||||
|
def destroy
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
@user.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to users_url, notice: t('action.destroy.successfull', model: User.model_name.human) }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
module ApplicationHelper
|
||||||
|
def title(*args)
|
||||||
|
content_tag :h1 do
|
||||||
|
if args.first.is_a?(Symbol) && (args[1].respond_to?(:model_name) || args[1].class.respond_to?(:model_name))
|
||||||
|
model = args[1].respond_to?(:model_name) ? args[1] : args[1].class
|
||||||
|
if args.first == :index
|
||||||
|
t('action.index.label', models: model.model_name.human_plural)
|
||||||
|
else
|
||||||
|
t("action.#{args.first}.label", model: model.model_name.human)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
args.first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def are_you_sure?
|
||||||
|
t('helpers.links.are_you_sure')
|
||||||
|
end
|
||||||
|
|
||||||
|
def list_open?
|
||||||
|
session[:list_id].present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def no_content_given(model)
|
||||||
|
t('helpers.list.no_records')
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
class List
|
||||||
|
include SimplyStored::Couch
|
||||||
|
|
||||||
|
property :state
|
||||||
|
property :closed_at, type: Time
|
||||||
|
has_many :orders
|
||||||
|
belongs_to :table
|
||||||
|
has_and_belongs_to_many :users, storing_keys: true
|
||||||
|
|
||||||
|
validates :table_id, presence: true
|
||||||
|
|
||||||
|
def close!
|
||||||
|
self.state = 'closed'
|
||||||
|
self.closed_at = Time.now
|
||||||
|
save
|
||||||
|
end
|
||||||
|
|
||||||
|
def supplier
|
||||||
|
table.supplier
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class Order
|
||||||
|
include SimplyStored::Couch
|
||||||
|
|
||||||
|
belongs_to :list
|
||||||
|
belongs_to :user
|
||||||
|
|
||||||
|
has_many :product_orders
|
||||||
|
has_many :products, through: :product_orders
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
class Product
|
||||||
|
include SimplyStored::Couch
|
||||||
|
|
||||||
|
property :name
|
||||||
|
property :code
|
||||||
|
property :price
|
||||||
|
|
||||||
|
belongs_to :product_category
|
||||||
|
belongs_to :supplier # direct! category is an aid
|
||||||
|
has_many :product_orders
|
||||||
|
|
||||||
|
validates :supplier_id, presence: true
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class ProductCategory
|
||||||
|
include SimplyStored::Couch
|
||||||
|
|
||||||
|
property :name
|
||||||
|
belongs_to :supplier
|
||||||
|
has_many :products
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class ProductOrder
|
||||||
|
include SimplyStored::Couch
|
||||||
|
|
||||||
|
belongs_to :product
|
||||||
|
belongs_to :order
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class Supplier
|
||||||
|
include SimplyStored::Couch
|
||||||
|
|
||||||
|
property :name
|
||||||
|
has_many :lists
|
||||||
|
has_many :orders, through: :lists
|
||||||
|
has_many :products
|
||||||
|
has_many :product_categories
|
||||||
|
has_many :tables
|
||||||
|
end
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
class Table
|
||||||
|
include SimplyStored::Couch
|
||||||
|
|
||||||
|
property :number, type: Fixnum, default: 1
|
||||||
|
|
||||||
|
belongs_to :supplier
|
||||||
|
has_many :lists
|
||||||
|
|
||||||
|
validates :supplier_id, presence: true
|
||||||
|
#validates :list_id, presence: true
|
||||||
|
validates :number, numericality: {greater_than: 0}
|
||||||
|
|
||||||
|
view :active_lists, type: :custom, map_function: %|function(doc){
|
||||||
|
if(doc.ruby_class == 'List' && doc.state == 'active'){
|
||||||
|
emit(doc._id, 1);
|
||||||
|
}
|
||||||
|
}|, reduce_function: '_sum'
|
||||||
|
|
||||||
|
def occupied?
|
||||||
|
not self.class.database.view(self.class.active_lists(key: list_id, reduce: true)).zero?
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class User
|
||||||
|
include SimplyStored::Couch
|
||||||
|
include Devise::Orm::SimplyStored
|
||||||
|
devise :database_authenticatable, :recoverable, :rememberable, :trackable
|
||||||
|
|
||||||
|
has_and_belongs_to_many :lists, storing_keys: false
|
||||||
|
has_many :orders
|
||||||
|
|
||||||
|
validates_uniqueness_of :email
|
||||||
|
end
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-if target.errors.any?
|
||||||
|
#error_explanation
|
||||||
|
.errors-content
|
||||||
|
%h2= t('helpers.forms.errors.title', :count => target.errors.count)
|
||||||
|
%ul
|
||||||
|
- for message in target.errors.full_messages
|
||||||
|
%li= message
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
.page-header= title 'Home'
|
||||||
|
ul.nav.nav-tabs.nav-stacked
|
||||||
|
- if list_open?
|
||||||
|
li.active= link_to '€ 23,45'.html_safe, '#'
|
||||||
|
li= link_to 'Place order', '/show_products?supplier_id=' + active_list.supplier.id
|
||||||
|
li= link_to 'Active list', '#'
|
||||||
|
li= link_to 'Request bill', '#'
|
||||||
|
li= link_to 'I have a question', '#'
|
||||||
|
- else
|
||||||
|
li= link_to 'Place order', '/select_qrcode'
|
||||||
|
li= link_to 'Subscribe to list', '#'
|
||||||
|
|
||||||
|
ul.nav.nav-tabs.nav-stacked
|
||||||
|
li= link_to 'View history', '#'
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
.page-header= title 'Select Qr code'
|
||||||
|
ul
|
||||||
|
- for table in @tables
|
||||||
|
li= link_to image_tag(url_for(qrcode_table_path(table, format: :png))), {action: :create_list, table_id: table.id}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
table#products-table.table.table-striped.table-hover
|
||||||
|
tbody
|
||||||
|
- content_for :footer do
|
||||||
|
javascript:
|
||||||
|
jQuery(function(){
|
||||||
|
$.get('#{product_list_supplier_path(@supplier, format: :json).html_safe}', function(res){
|
||||||
|
window.products = res
|
||||||
|
body = $('#products-table tbody')
|
||||||
|
for(category in window.products){
|
||||||
|
body.append('<tr><td><h3>'+category+'<h3></td></tr>')
|
||||||
|
for(iproduct in window.products[category]){
|
||||||
|
body.append('<tr><td>'+window.products[category][iproduct].name+'</td></tr>')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
doctype html
|
||||||
|
html lang="en"
|
||||||
|
head
|
||||||
|
meta charset="utf-8"
|
||||||
|
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
||||||
|
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
||||||
|
title= content_for?(:title) ? yield(:title) : "Qrammer"
|
||||||
|
= csrf_meta_tags
|
||||||
|
|
||||||
|
/! Le HTML5 shim, for IE6-8 support of HTML elements
|
||||||
|
/[if lt IE 9]
|
||||||
|
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||||
|
= stylesheet_link_tag "application", :media => "all"
|
||||||
|
link href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
||||||
|
link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
||||||
|
link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
||||||
|
link href="images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"
|
||||||
|
link href="images/favicon.ico" rel="shortcut icon"
|
||||||
|
|
||||||
|
body
|
||||||
|
.navbar.navbar-fixed-top
|
||||||
|
.navbar-inner
|
||||||
|
.container
|
||||||
|
a.btn.btn-navbar data-target=".nav-collapse" data-toggle="collapse"
|
||||||
|
span.icon-bar
|
||||||
|
span.icon-bar
|
||||||
|
span.icon-bar
|
||||||
|
a.brand href=root_path Qrammer
|
||||||
|
.container.nav-collapse
|
||||||
|
ul.nav
|
||||||
|
li= link_to User.model_name.human_plural, users_path
|
||||||
|
li= link_to Supplier.model_name.human_plural, suppliers_path
|
||||||
|
li= link_to Table.model_name.human_plural, tables_path
|
||||||
|
li= link_to Product.model_name.human_plural, products_path
|
||||||
|
li= link_to List.model_name.human_plural, lists_path
|
||||||
|
li= link_to ProductCategory.model_name.human_plural, product_categories_path
|
||||||
|
|
||||||
|
.container
|
||||||
|
|
||||||
|
.content
|
||||||
|
- if flash[:alert].present?
|
||||||
|
.alert.alert-error
|
||||||
|
a.close data-dismiss="alert" ×
|
||||||
|
div= flash[:alert]
|
||||||
|
- if flash[:notice].present?
|
||||||
|
.alert.alert-success
|
||||||
|
a.close data-dismiss="alert" ×
|
||||||
|
div= flash[:notice]
|
||||||
|
.row
|
||||||
|
.span9
|
||||||
|
= yield
|
||||||
|
.span3
|
||||||
|
.well.sidebar-nav
|
||||||
|
h3 Sidebar
|
||||||
|
ul.nav.nav-list
|
||||||
|
li.nav-header Sidebar
|
||||||
|
li= link_to "Link 1", "/path1"
|
||||||
|
li= link_to "Link 2", "/path2"
|
||||||
|
li= link_to "Link 3", "/path3"
|
||||||
|
|
||||||
|
footer
|
||||||
|
p © Companytools 2012
|
||||||
|
/!
|
||||||
|
Javascripts
|
||||||
|
\==================================================
|
||||||
|
/! Placed at the end of the document so the pages load faster
|
||||||
|
= javascript_include_tag "application"
|
||||||
|
= yield :footer
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
= form_for @list, html: {class: 'form-horizontal' } do |f|
|
||||||
|
= render 'error_messages', target: @list
|
||||||
|
.control-group class=(@list.errors[:state].any? ? 'error' : nil)
|
||||||
|
= f.label :state, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :state, class: 'text_field'
|
||||||
|
.control-group class=(@list.errors[:closed_at].any? ? 'error' : nil)
|
||||||
|
= f.label :closed_at, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :closed_at, class: 'text_field'
|
||||||
|
.control-group class=(@list.errors[:table_id].any? ? 'error' : nil)
|
||||||
|
= f.label :table_id, Table.model_name.human, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.select :table_id, options_for_select(@tables.map{|a| [a.number, a.id]}), include_blank: nil
|
||||||
|
.form-actions
|
||||||
|
= f.submit nil, class: 'btn btn-primary'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.cancel"), lists_path, class: 'btn'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = List
|
||||||
|
.page-header
|
||||||
|
= title :edit, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
- model_class = List
|
||||||
|
div.page-header= title :index, model_class
|
||||||
|
- if @lists.any?
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th= model_class.human_attribute_name(:state)
|
||||||
|
th= model_class.human_attribute_name(:closed_at)
|
||||||
|
th= Table.model_name.human
|
||||||
|
th= model_class.human_attribute_name(:created_at)
|
||||||
|
th=t 'helpers.actions'
|
||||||
|
tbody
|
||||||
|
- @lists.each do |list|
|
||||||
|
tr
|
||||||
|
td= link_to list.state, list
|
||||||
|
td= list.closed_at
|
||||||
|
td= link_to list.table.number, list.table
|
||||||
|
td=l list.created_at, format: :short
|
||||||
|
td
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, list], class: 'btn btn-mini'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), list, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||||
|
- else
|
||||||
|
= no_content_given model_class
|
||||||
|
= link_to t("helpers.links.new"), new_list_path, class: 'btn btn-primary'
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = List
|
||||||
|
.page-header
|
||||||
|
= title :new, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
- model_class = List
|
||||||
|
.page-header= title :show, @list
|
||||||
|
|
||||||
|
dl.dl-horizontal.show-list
|
||||||
|
dt= model_class.human_attribute_name(:state)
|
||||||
|
dd= @list.state
|
||||||
|
dt= model_class.human_attribute_name(:closed_at)
|
||||||
|
dd= @list.closed_at
|
||||||
|
- if @list.table.present?
|
||||||
|
dt= Table.model_name.human
|
||||||
|
dd= link_to @list.table.number, @list.table
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= link_to t("helpers.links.back"), lists_path, class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, @list], class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), @list, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
= form_for @product_category, html: {class: 'form-horizontal' } do |f|
|
||||||
|
= render 'error_messages', target: @product_category
|
||||||
|
.control-group class=(@product_category.errors[:name].any? ? 'error' : nil)
|
||||||
|
= f.label :name, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :name, class: 'text_field'
|
||||||
|
.control-group class=(@product_category.errors[:supplier_id].any? ? 'error' : nil)
|
||||||
|
= f.label :supplier_id, Supplier.model_name.human, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.select :supplier_id, options_for_select(@suppliers.map{|a| [a.name, a.id]}), include_blank: nil
|
||||||
|
.form-actions
|
||||||
|
= f.submit nil, class: 'btn btn-primary'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.cancel"), product_categories_path, class: 'btn'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = ProductCategory
|
||||||
|
.page-header
|
||||||
|
= title :edit, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
- model_class = ProductCategory
|
||||||
|
div.page-header= title :index, model_class
|
||||||
|
- if @product_categories.any?
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th= model_class.human_attribute_name(:name)
|
||||||
|
th= Supplier.model_name.human
|
||||||
|
th= model_class.human_attribute_name(:created_at)
|
||||||
|
th=t 'helpers.actions'
|
||||||
|
tbody
|
||||||
|
- @product_categories.each do |product_category|
|
||||||
|
tr
|
||||||
|
td= link_to product_category.name, product_category
|
||||||
|
td= link_to product_category.supplier.name, product_category.supplier
|
||||||
|
td=l product_category.created_at, format: :short
|
||||||
|
td
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, product_category], class: 'btn btn-mini'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), product_category, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||||
|
- else
|
||||||
|
= no_content_given model_class
|
||||||
|
= link_to t("helpers.links.new"), new_product_category_path, class: 'btn btn-primary'
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = ProductCategory
|
||||||
|
.page-header
|
||||||
|
= title :new, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
- model_class = ProductCategory
|
||||||
|
.page-header= title :show, @product_category
|
||||||
|
|
||||||
|
dl.dl-horizontal.show-list
|
||||||
|
dt= model_class.human_attribute_name(:name)
|
||||||
|
dd= @product_category.name
|
||||||
|
dt= Supplier.model_name.human
|
||||||
|
dd= link_to @product_category.supplier.name, @product_category.supplier
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= link_to t("helpers.links.back"), product_categories_path, class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, @product_category], class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), @product_category, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
= form_for @product, html: {class: 'form-horizontal' } do |f|
|
||||||
|
= render 'error_messages', target: @product
|
||||||
|
.control-group class=(@product.errors[:name].any? ? 'error' : nil)
|
||||||
|
= f.label :name, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :name, class: 'text_field'
|
||||||
|
.control-group class=(@product.errors[:code].any? ? 'error' : nil)
|
||||||
|
= f.label :code, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :code, class: 'text_field'
|
||||||
|
.control-group class=(@product.errors[:price].any? ? 'error' : nil)
|
||||||
|
= f.label :price, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :price, class: 'text_field'
|
||||||
|
.control-group class=(@product.errors[:product_category_id].any? ? 'error' : nil)
|
||||||
|
= f.label :product_category_id, ProductCategory.model_name.human, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.select :product_category_id, options_for_select(@product_categories.map{|a| [a.name, a.id]}), include_blank: ''
|
||||||
|
.control-group class=(@product.errors[:supplier_id].any? ? 'error' : nil)
|
||||||
|
= f.label :supplier_id, Supplier.model_name.human, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.select :supplier_id, options_for_select(@suppliers.map{|a| [a.name, a.id]}), include_blank: nil
|
||||||
|
.form-actions
|
||||||
|
= f.submit nil, class: 'btn btn-primary'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.cancel"), products_path, class: 'btn'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = Product
|
||||||
|
.page-header
|
||||||
|
= title :edit, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
- model_class = Product
|
||||||
|
div.page-header= title :index, model_class
|
||||||
|
- if @products.any?
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th= model_class.human_attribute_name(:name)
|
||||||
|
th= model_class.human_attribute_name(:code)
|
||||||
|
th= model_class.human_attribute_name(:price)
|
||||||
|
th= ProductCategory.model_name.human
|
||||||
|
th= Supplier.model_name.human
|
||||||
|
th= model_class.human_attribute_name(:created_at)
|
||||||
|
th=t 'helpers.actions'
|
||||||
|
tbody
|
||||||
|
- @products.each do |product|
|
||||||
|
tr
|
||||||
|
td= link_to product.name, product
|
||||||
|
td= product.code
|
||||||
|
td= product.price
|
||||||
|
td= link_to product.product_category.name, product.product_category
|
||||||
|
td= link_to product.supplier.name, product.supplier
|
||||||
|
td=l product.created_at, format: :short
|
||||||
|
td
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, product], class: 'btn btn-mini'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), product, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||||
|
- else
|
||||||
|
= no_content_given model_class
|
||||||
|
= link_to t("helpers.links.new"), new_product_path, class: 'btn btn-primary'
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = Product
|
||||||
|
.page-header
|
||||||
|
= title :new, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
- model_class = Product
|
||||||
|
.page-header= title :show, @product
|
||||||
|
|
||||||
|
dl.dl-horizontal.show-list
|
||||||
|
dt= model_class.human_attribute_name(:name)
|
||||||
|
dd= @product.name
|
||||||
|
dt= model_class.human_attribute_name(:code)
|
||||||
|
dd= @product.code
|
||||||
|
dt= model_class.human_attribute_name(:price)
|
||||||
|
dd= @product.price
|
||||||
|
- if @product.product_category.present?
|
||||||
|
dt= ProductCategory.model_name.human
|
||||||
|
dd= link_to @product.product_category.name, @product.product_category
|
||||||
|
- if @product.supplier.present?
|
||||||
|
dt= Supplier.model_name.human
|
||||||
|
dd= link_to @product.supplier.name, @product.supplier
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= link_to t("helpers.links.back"), products_path, class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, @product], class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), @product, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
= form_for @supplier, html: {class: 'form-horizontal' } do |f|
|
||||||
|
= render 'error_messages', target: @supplier
|
||||||
|
.control-group class=(@supplier.errors[:name].any? ? 'error' : nil)
|
||||||
|
= f.label :name, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :name, class: 'text_field'
|
||||||
|
.form-actions
|
||||||
|
= f.submit nil, class: 'btn btn-primary'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.cancel"), suppliers_path, class: 'btn'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = Supplier
|
||||||
|
.page-header
|
||||||
|
= title :edit, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
- model_class = Supplier
|
||||||
|
div.page-header= title :index, model_class
|
||||||
|
- if @suppliers.any?
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th= model_class.human_attribute_name(:name)
|
||||||
|
th= model_class.human_attribute_name(:created_at)
|
||||||
|
th=t 'helpers.actions'
|
||||||
|
tbody
|
||||||
|
- @suppliers.each do |supplier|
|
||||||
|
tr
|
||||||
|
td= link_to supplier.name, supplier
|
||||||
|
td=l supplier.created_at, format: :short
|
||||||
|
td
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, supplier], class: 'btn btn-mini'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), supplier, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||||
|
- else
|
||||||
|
= no_content_given model_class
|
||||||
|
= link_to t("helpers.links.new"), new_supplier_path, class: 'btn btn-primary'
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = Supplier
|
||||||
|
.page-header
|
||||||
|
= title :new, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
- model_class = Supplier
|
||||||
|
.page-header
|
||||||
|
= title :show, @supplier
|
||||||
|
|
||||||
|
dl.dl-horizontal.show-list
|
||||||
|
dt= model_class.human_attribute_name(:name) + ':'
|
||||||
|
dd= @supplier.name
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= link_to t("helpers.links.back"), suppliers_path, class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, @supplier], class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), @supplier, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
= form_for @table, html: {class: 'form-horizontal' } do |f|
|
||||||
|
= render 'error_messages', target: @table
|
||||||
|
.control-group class=(@table.errors[:number].any? ? 'error' : nil)
|
||||||
|
= f.label :number, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :number, class: 'text_field'
|
||||||
|
.control-group class=(@table.errors[:supplier_id].any? ? 'error' : nil)
|
||||||
|
= f.label :supplier_id, Supplier.model_name.human, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.select :supplier_id, options_for_select(@suppliers.map{|a| [a.name, a.id]}), include_blank: nil
|
||||||
|
.form-actions
|
||||||
|
= f.submit nil, class: 'btn btn-primary'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.cancel"), tables_path, class: 'btn'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = Table
|
||||||
|
.page-header
|
||||||
|
= title :edit, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
- model_class = Table
|
||||||
|
div.page-header= title :index, model_class
|
||||||
|
- if @tables.any?
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th= model_class.human_attribute_name(:number)
|
||||||
|
th= Supplier.model_name.human
|
||||||
|
th= model_class.human_attribute_name(:created_at)
|
||||||
|
th=t 'helpers.actions'
|
||||||
|
tbody
|
||||||
|
- @tables.each do |table|
|
||||||
|
tr
|
||||||
|
td= link_to table.number, table
|
||||||
|
td= link_to table.supplier.name, table.supplier
|
||||||
|
td=l table.created_at, format: :short
|
||||||
|
td
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, table], class: 'btn btn-mini'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), table, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||||
|
- else
|
||||||
|
= no_content_given model_class
|
||||||
|
= link_to t("helpers.links.new"), new_table_path, class: 'btn btn-primary'
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = Table
|
||||||
|
.page-header
|
||||||
|
= title :new, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
- model_class = Table
|
||||||
|
.page-header= title :show, @table
|
||||||
|
|
||||||
|
dl.dl-horizontal.show-list
|
||||||
|
dt= model_class.human_attribute_name(:number)
|
||||||
|
dd= @table.number
|
||||||
|
- if @table.supplier.present?
|
||||||
|
dt= Supplier.model_name.human
|
||||||
|
dd= link_to @table.supplier.name, @table.supplier
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= link_to t("helpers.links.back"), tables_path, class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, @table], class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), @table, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
= form_for @user, html: {class: 'form-horizontal' } do |f|
|
||||||
|
.control-group
|
||||||
|
= f.label :email, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :email, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :encrypted_password, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :encrypted_password, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :remember_token, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :remember_token, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :remember_created_at, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :remember_created_at, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :reset_password_token, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :reset_password_token, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :sign_in_count, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :sign_in_count, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :current_sign_in_at, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :current_sign_in_at, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :last_sign_in_at, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :last_sign_in_at, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :current_sign_in_ip, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :current_sign_in_ip, class: 'text_field'
|
||||||
|
.control-group
|
||||||
|
= f.label :last_sign_in_ip, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :last_sign_in_ip, class: 'text_field'
|
||||||
|
.form-actions
|
||||||
|
= f.submit nil, class: 'btn btn-primary'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.cancel"), users_path, class: 'btn'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = User
|
||||||
|
.page-header
|
||||||
|
= title :edit, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
- model_class = User
|
||||||
|
div class="page-header"= title :index, model_class
|
||||||
|
table class="table table-striped"
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th= model_class.human_attribute_name(:email)
|
||||||
|
th= model_class.human_attribute_name(:encrypted_password)
|
||||||
|
th= model_class.human_attribute_name(:remember_token)
|
||||||
|
th= model_class.human_attribute_name(:remember_created_at)
|
||||||
|
th= model_class.human_attribute_name(:reset_password_token)
|
||||||
|
th= model_class.human_attribute_name(:sign_in_count)
|
||||||
|
th= model_class.human_attribute_name(:current_sign_in_at)
|
||||||
|
th= model_class.human_attribute_name(:last_sign_in_at)
|
||||||
|
th= model_class.human_attribute_name(:current_sign_in_ip)
|
||||||
|
th= model_class.human_attribute_name(:last_sign_in_ip)
|
||||||
|
th= model_class.human_attribute_name(:created_at)
|
||||||
|
th=t 'helpers.actions'
|
||||||
|
tbody
|
||||||
|
- @users.each do |user|
|
||||||
|
tr
|
||||||
|
td= link_to user.email, user
|
||||||
|
td= user.encrypted_password
|
||||||
|
td= user.remember_token
|
||||||
|
td= user.remember_created_at
|
||||||
|
td= user.reset_password_token
|
||||||
|
td= user.sign_in_count
|
||||||
|
td= user.current_sign_in_at
|
||||||
|
td= user.last_sign_in_at
|
||||||
|
td= user.current_sign_in_ip
|
||||||
|
td= user.last_sign_in_ip
|
||||||
|
td=l user.created_at, format: :short
|
||||||
|
td
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, user], class: 'btn btn-mini'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), user, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||||
|
|
||||||
|
= link_to t("helpers.links.new"), new_user_path, class: 'btn btn-primary'
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = User
|
||||||
|
.page-header
|
||||||
|
= title :new, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
- model_class = User
|
||||||
|
.page-header
|
||||||
|
= title :show, @user
|
||||||
|
|
||||||
|
dl.dl-horizontal.show-list
|
||||||
|
dt= model_class.human_attribute_name(:email) + ':'
|
||||||
|
dd= @user.email
|
||||||
|
dt= model_class.human_attribute_name(:encrypted_password) + ':'
|
||||||
|
dd= @user.encrypted_password
|
||||||
|
dt= model_class.human_attribute_name(:remember_token) + ':'
|
||||||
|
dd= @user.remember_token
|
||||||
|
dt= model_class.human_attribute_name(:remember_created_at) + ':'
|
||||||
|
dd= @user.remember_created_at
|
||||||
|
dt= model_class.human_attribute_name(:reset_password_token) + ':'
|
||||||
|
dd= @user.reset_password_token
|
||||||
|
dt= model_class.human_attribute_name(:sign_in_count) + ':'
|
||||||
|
dd= @user.sign_in_count
|
||||||
|
dt= model_class.human_attribute_name(:current_sign_in_at) + ':'
|
||||||
|
dd= @user.current_sign_in_at
|
||||||
|
dt= model_class.human_attribute_name(:last_sign_in_at) + ':'
|
||||||
|
dd= @user.last_sign_in_at
|
||||||
|
dt= model_class.human_attribute_name(:current_sign_in_ip) + ':'
|
||||||
|
dd= @user.current_sign_in_ip
|
||||||
|
dt= model_class.human_attribute_name(:last_sign_in_ip) + ':'
|
||||||
|
dd= @user.last_sign_in_ip
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= link_to t("helpers.links.back"), users_path, class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, @user], class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), @user, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# This file is used by Rack-based servers to start the application.
|
||||||
|
|
||||||
|
require ::File.expand_path('../config/environment', __FILE__)
|
||||||
|
run Qrammer::Application
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
require File.expand_path('../boot', __FILE__)
|
||||||
|
|
||||||
|
#require 'rails/all'
|
||||||
|
require 'rails'
|
||||||
|
#require 'active_record/railtie'
|
||||||
|
require 'action_controller/railtie'
|
||||||
|
require 'action_mailer/railtie'
|
||||||
|
require 'active_resource/railtie'
|
||||||
|
require 'rails/test_unit/railtie'
|
||||||
|
require 'sprockets/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 Qrammer
|
||||||
|
class Application < Rails::Application
|
||||||
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
|
# Application configuration should go into files in config/initializers
|
||||||
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
|
|
||||||
|
# Custom directories with classes and modules you want to be autoloadable.
|
||||||
|
# config.autoload_paths += %W(#{config.root}/extras)
|
||||||
|
|
||||||
|
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||||
|
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||||
|
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||||
|
|
||||||
|
# Activate observers that should always be running.
|
||||||
|
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
||||||
|
|
||||||
|
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||||
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||||
|
# config.time_zone = 'Central Time (US & Canada)'
|
||||||
|
|
||||||
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||||
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||||
|
# config.i18n.default_locale = :de
|
||||||
|
|
||||||
|
# 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 escaping HTML in JSON.
|
||||||
|
config.active_support.escape_html_entities_in_json = true
|
||||||
|
|
||||||
|
config.generators do |g|
|
||||||
|
g.orm :simply_stored
|
||||||
|
g.template_engine :slim
|
||||||
|
g.test_framework :rspec
|
||||||
|
end
|
||||||
|
|
||||||
|
# Use SQL instead of Active Record's schema dumper when creating the database.
|
||||||
|
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
||||||
|
# like if you have constraints or database-specific column types
|
||||||
|
# config.active_record.schema_format = :sql
|
||||||
|
|
||||||
|
config.action_view.field_error_proc = Proc.new do |html_tag, instance|
|
||||||
|
"#{html_tag}".html_safe
|
||||||
|
end
|
||||||
|
|
||||||
|
# Enforce whitelist mode for mass assignment.
|
||||||
|
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
||||||
|
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
||||||
|
# parameters by using an attr_accessible or attr_protected declaration.
|
||||||
|
# config.active_record.whitelist_attributes = true
|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
require 'rubygems'
|
||||||
|
|
||||||
|
# Set up gems listed in the Gemfile.
|
||||||
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||||
|
|
||||||
|
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
development:
|
||||||
|
validation_framework: :active_model #optional
|
||||||
|
database: qrammer_development
|
||||||
|
test:
|
||||||
|
validation_framework: :active_model #optional
|
||||||
|
database: qrammer_test
|
||||||
|
production:
|
||||||
|
validation_framework: :active_model #optional
|
||||||
|
database: qrammer
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# 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
|
||||||
|
pool: 5
|
||||||
|
timeout: 5000
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
adapter: sqlite3
|
||||||
|
database: db/test.sqlite3
|
||||||
|
pool: 5
|
||||||
|
timeout: 5000
|
||||||
|
|
||||||
|
production:
|
||||||
|
adapter: sqlite3
|
||||||
|
database: db/production.sqlite3
|
||||||
|
pool: 5
|
||||||
|
timeout: 5000
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Load the rails application
|
||||||
|
require File.expand_path('../application', __FILE__)
|
||||||
|
|
||||||
|
# Initialize the rails application
|
||||||
|
Qrammer::Application.initialize!
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
Qrammer::Application.configure do
|
||||||
|
# Settings specified here will take precedence over those in config/application.rb
|
||||||
|
|
||||||
|
# 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 web server when you make code changes.
|
||||||
|
config.cache_classes = false
|
||||||
|
|
||||||
|
# Log error messages when you accidentally call methods on nil.
|
||||||
|
config.whiny_nils = true
|
||||||
|
|
||||||
|
# Show full error reports and disable caching
|
||||||
|
config.consider_all_requests_local = true
|
||||||
|
config.action_controller.perform_caching = false
|
||||||
|
|
||||||
|
# Don't care if the mailer can't send
|
||||||
|
config.action_mailer.raise_delivery_errors = false
|
||||||
|
|
||||||
|
# Print deprecation notices to the Rails logger
|
||||||
|
config.active_support.deprecation = :log
|
||||||
|
|
||||||
|
# Only use best-standards-support built into browsers
|
||||||
|
config.action_dispatch.best_standards_support = :builtin
|
||||||
|
|
||||||
|
# Raise exception on mass assignment protection for Active Record models
|
||||||
|
# config.active_record.mass_assignment_sanitizer = :strict
|
||||||
|
|
||||||
|
# Log the query plan for queries taking more than this (works
|
||||||
|
# with SQLite, MySQL, and PostgreSQL)
|
||||||
|
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||||
|
|
||||||
|
# Do not compress assets
|
||||||
|
config.assets.compress = false
|
||||||
|
|
||||||
|
# Expands the lines which load the assets
|
||||||
|
config.assets.debug = true
|
||||||
|
end
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
Qrammer::Application.configure do
|
||||||
|
# Settings specified here will take precedence over those in config/application.rb
|
||||||
|
|
||||||
|
# Code is not reloaded between requests
|
||||||
|
config.cache_classes = true
|
||||||
|
|
||||||
|
# Full error reports are disabled and caching is turned on
|
||||||
|
config.consider_all_requests_local = false
|
||||||
|
config.action_controller.perform_caching = true
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Defaults to nil and saved in location specified by config.assets.prefix
|
||||||
|
# config.assets.manifest = YOUR_PATH
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Prepend all log lines with the following tags
|
||||||
|
# config.log_tags = [ :subdomain, :uuid ]
|
||||||
|
|
||||||
|
# Use a different logger for distributed setups
|
||||||
|
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
||||||
|
|
||||||
|
# Use a different cache store in production
|
||||||
|
# config.cache_store = :mem_cache_store
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Enable threaded mode
|
||||||
|
# config.threadsafe!
|
||||||
|
|
||||||
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||||
|
# the I18n.default_locale when a translation can not be found)
|
||||||
|
config.i18n.fallbacks = true
|
||||||
|
|
||||||
|
# Send deprecation notices to registered listeners
|
||||||
|
config.active_support.deprecation = :notify
|
||||||
|
|
||||||
|
# Log the query plan for queries taking more than this (works
|
||||||
|
# with SQLite, MySQL, and PostgreSQL)
|
||||||
|
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||||
|
end
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
Qrammer::Application.configure do
|
||||||
|
# Settings specified here will take precedence over those in config/application.rb
|
||||||
|
|
||||||
|
# The test environment is used exclusively to run your application's
|
||||||
|
# test suite. You never need to work with it otherwise. Remember that
|
||||||
|
# your test database is "scratch space" for the test suite and is wiped
|
||||||
|
# and recreated between test runs. Don't rely on the data there!
|
||||||
|
config.cache_classes = true
|
||||||
|
|
||||||
|
# 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
|
||||||
|
config.consider_all_requests_local = true
|
||||||
|
config.action_controller.perform_caching = false
|
||||||
|
|
||||||
|
# Raise exceptions instead of rendering exception templates
|
||||||
|
config.action_dispatch.show_exceptions = false
|
||||||
|
|
||||||
|
# Disable request forgery protection in test environment
|
||||||
|
config.action_controller.allow_forgery_protection = false
|
||||||
|
|
||||||
|
# Tell Action Mailer not to deliver emails to the real world.
|
||||||
|
# The :test delivery method accumulates sent emails in the
|
||||||
|
# ActionMailer::Base.deliveries array.
|
||||||
|
config.action_mailer.delivery_method = :test
|
||||||
|
|
||||||
|
# Raise exception on mass assignment protection for Active Record models
|
||||||
|
# config.active_record.mass_assignment_sanitizer = :strict
|
||||||
|
|
||||||
|
# Print deprecation notices to the stderr
|
||||||
|
config.active_support.deprecation = :stderr
|
||||||
|
end
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||||
|
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||||
|
|
||||||
|
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||||
|
# Rails.backtrace_cleaner.remove_silencers!
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Add new inflection rules using the following format
|
||||||
|
# (all these examples are active by default):
|
||||||
|
# ActiveSupport::Inflector.inflections do |inflect|
|
||||||
|
# inflect.plural /^(ox)$/i, '\1en'
|
||||||
|
# inflect.singular /^(ox)en/i, '\1'
|
||||||
|
# inflect.irregular 'person', 'people'
|
||||||
|
# inflect.uncountable %w( fish sheep )
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# These inflection rules are supported but not enabled by default:
|
||||||
|
# ActiveSupport::Inflector.inflections do |inflect|
|
||||||
|
# inflect.acronym 'RESTful'
|
||||||
|
# end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Add new mime types for use in respond_to blocks:
|
||||||
|
# Mime::Type.register "text/richtext", :rtf
|
||||||
|
# Mime::Type.register_alias "text/html", :iphone
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
module ActiveModel
|
||||||
|
class Name
|
||||||
|
def human_plural
|
||||||
|
I18n.t("activemodel.models.plural.#{underscore.gsub('/', '.')}", :default => nil ) || human.pluralize
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Your secret key for verifying the integrity of signed cookies.
|
||||||
|
# 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.
|
||||||
|
Qrammer::Application.config.secret_token = 'a2d0002614aa5e1a04dd5f57c3a239765ee47df0f5e3214adf41c4893b84a95cd805f650f5edb321f2474adf6bb01a625b911d34a3c879815281d7e1db4415c8'
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
Qrammer::Application.config.session_store :cookie_store, key: '_qrammer_session'
|
||||||
|
|
||||||
|
# Use the database for sessions instead of the cookie-based default,
|
||||||
|
# which shouldn't be used to store highly confidential information
|
||||||
|
# (create the session table with "rails generate session_migration")
|
||||||
|
# Qrammer::Application.config.session_store :active_record_store
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Sample localization file for English. Add more files in this directory for other locales.
|
||||||
|
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||||
|
|
||||||
|
en:
|
||||||
|
hello: "Hello world"
|
||||||
|
helpers:
|
||||||
|
links:
|
||||||
|
are_you_sure: 'Are you sure?'
|
||||||
|
forms:
|
||||||
|
errors:
|
||||||
|
title: There are problems found during saving (%{count})
|
||||||
|
action:
|
||||||
|
index:
|
||||||
|
label: Listing %{models}
|
||||||
|
new:
|
||||||
|
label: New %{model}
|
||||||
|
show:
|
||||||
|
label: Showing %{model}
|
||||||
|
create:
|
||||||
|
successfull: '%{model} is successfully created'
|
||||||
|
update:
|
||||||
|
successfull: '%{model} is successfully updated'
|
||||||
|
destroy:
|
||||||
|
successfull: '%{model} is successfully destroyed'
|
||||||
|
table:
|
||||||
|
is_occupied: This table is occupied
|
||||||
|
activemodel:
|
||||||
|
models:
|
||||||
|
user: User
|
||||||
|
supplier: Restaurant
|
||||||
|
table: Table
|
||||||
|
list: List
|
||||||
|
product: Product
|
||||||
|
product_category: Product category
|
||||||
|
plural:
|
||||||
|
user: Users
|
||||||
|
supplier: Restaurants
|
||||||
|
table: Tables
|
||||||
|
list: Lists
|
||||||
|
product: Products
|
||||||
|
product_category: Product categories
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
Qrammer::Application.routes.draw do
|
||||||
|
resources :users
|
||||||
|
resources :tables do
|
||||||
|
member do
|
||||||
|
get :qrcode
|
||||||
|
end
|
||||||
|
end
|
||||||
|
resources :suppliers do
|
||||||
|
member do
|
||||||
|
get :product_list
|
||||||
|
end
|
||||||
|
end
|
||||||
|
resources :lists
|
||||||
|
resources :products
|
||||||
|
resources :product_categories
|
||||||
|
|
||||||
|
match "/:action", controller: 'dashboard'
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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 => 'dashboard#home'
|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# This file should contain all the record creation needed to seed the database with its default values.
|
||||||
|
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
#
|
||||||
|
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||||
|
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Use this README file to introduce your application and point to useful places in the API for learning more.
|
||||||
|
Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
= form_for @<%= resource_name %>, html: {class: 'form-horizontal' } do |f|
|
||||||
|
= render 'error_messages', target: @<%= resource_name %>
|
||||||
|
<%- columns.each do |column| -%>
|
||||||
|
.control-group class=(@<%= resource_name %>.errors[:<%= column.name %>].any? ? 'error' : nil)
|
||||||
|
= f.label :<%= column.name %>, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.<%= column.field_type %> :<%= column.name %>, class: '<%= column.field_type %>'
|
||||||
|
<%- end -%>
|
||||||
|
<%- belongs_to_associations.each do |association| -%>
|
||||||
|
.control-group class=(@<%= resource_name %>.errors[:<%= association.name %>_id].any? ? 'error' : nil)
|
||||||
|
= f.label :<%= association.name %>_id, <%= association.options[:class_name] %>.model_name.human, class: 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.select :<%= association.name %>_id, options_for_select(@<%= association.name.to_s.pluralize %>.map{|a| [a.<%= association.name_property%>, a.id]}), include_blank: <%= model_name.constantize.validators_on(:"#{association.name}_id").any? ? 'nil' : "''" %>
|
||||||
|
<%- end -%>
|
||||||
|
.form-actions
|
||||||
|
= f.submit nil, class: 'btn btn-primary'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.cancel"), <%= controller_routing_path %>_path, class: 'btn'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = <%= resource_name.classify %>
|
||||||
|
.page-header
|
||||||
|
= title :edit, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
- model_class = <%= resource_name.classify %>
|
||||||
|
div.page-header= title :index, model_class
|
||||||
|
- if @<%= plural_resource_name %>.any?
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
<%- columns.each do |column| -%>
|
||||||
|
th= model_class.human_attribute_name(:<%= column.name %>)
|
||||||
|
<%- end -%>
|
||||||
|
<%- belongs_to_associations.each do |association| -%>
|
||||||
|
th= <%= association.options[:class_name] %>.model_name.human
|
||||||
|
<%- end -%>
|
||||||
|
th= model_class.human_attribute_name(:created_at)
|
||||||
|
th=t 'helpers.actions'
|
||||||
|
tbody
|
||||||
|
- @<%= plural_resource_name %>.each do |<%= resource_name %>|
|
||||||
|
tr
|
||||||
|
<%- columns.each.with_index do |column, index| -%>
|
||||||
|
<%- if index.zero? -%>
|
||||||
|
td= link_to <%= resource_name %>.<%= column.name %>, <%= resource_name %>
|
||||||
|
<%- else -%>
|
||||||
|
td= <%= resource_name %>.<%= column.name %>
|
||||||
|
<%- end end -%>
|
||||||
|
<%- belongs_to_associations.each do |association| -%>
|
||||||
|
td= link_to <%= resource_name %>.<%= association.name %>.<%= association.name_property %>, <%= resource_name %>.<%= association.name %>
|
||||||
|
<%- end -%>
|
||||||
|
td=l <%= resource_name %>.created_at, format: :short
|
||||||
|
td
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, <%= resource_name %>], class: 'btn btn-mini'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), <%= resource_name %>, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||||
|
- else
|
||||||
|
= no_content_given model_class
|
||||||
|
= link_to t("helpers.links.new"), new_<%= singular_controller_routing_path %>_path, class: 'btn btn-primary'
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- model_class = <%= resource_name.classify %>
|
||||||
|
.page-header
|
||||||
|
= title :new, model_class
|
||||||
|
= render 'form'
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
- model_class = <%= resource_name.classify %>
|
||||||
|
.page-header= title :show, @<%= resource_name %>
|
||||||
|
|
||||||
|
dl.dl-horizontal.show-list
|
||||||
|
<%- columns.each do |column| -%>
|
||||||
|
dt= model_class.human_attribute_name(:<%= column.name %>)
|
||||||
|
dd= @<%= resource_name %>.<%= column.name %>
|
||||||
|
<%- end -%>
|
||||||
|
<%- belongs_to_associations.each do |association| -%>
|
||||||
|
- if @<%= resource_name %>.<%= association.name %>.present?
|
||||||
|
dt= <%= association.options[:class_name] %>.model_name.human
|
||||||
|
dd= link_to @<%= resource_name %>.<%= association.name %>.<%= association.name_property %>, @<%= resource_name %>.<%= association.name %>
|
||||||
|
<%- end -%>
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= link_to t("helpers.links.back"), <%= controller_routing_path %>_path, class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t('helpers.links.edit'), [:edit, @<%= resource_name %>], class: 'btn'
|
||||||
|
'
|
||||||
|
= link_to t("helpers.links.destroy"), @<%= resource_name %>, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
require 'rails/generators'
|
||||||
|
require 'rails/generators/generated_attribute'
|
||||||
|
|
||||||
|
module Bootstrap
|
||||||
|
module Generators
|
||||||
|
class ThemedGenerator < ::Rails::Generators::Base
|
||||||
|
NAME_COLUMNS = %w[name title number].map(&:to_sym)
|
||||||
|
source_root File.expand_path('../templates', __FILE__)
|
||||||
|
argument :controller_path, :type => :string
|
||||||
|
argument :model_name, :type => :string, :required => false
|
||||||
|
argument :layout, :type => :string, :default => "application",
|
||||||
|
:banner => "Specify application layout"
|
||||||
|
|
||||||
|
def initialize(args, *options)
|
||||||
|
super(args, *options)
|
||||||
|
initialize_views_variables
|
||||||
|
end
|
||||||
|
|
||||||
|
def copy_views
|
||||||
|
generate_views
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def initialize_views_variables
|
||||||
|
@base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
|
||||||
|
@controller_routing_path = @controller_file_path.gsub(/\//, '_')
|
||||||
|
@model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
|
||||||
|
@model_name = @model_name.camelize
|
||||||
|
end
|
||||||
|
|
||||||
|
def controller_routing_path
|
||||||
|
@controller_routing_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def singular_controller_routing_path
|
||||||
|
@controller_routing_path.singularize
|
||||||
|
end
|
||||||
|
|
||||||
|
def model_name
|
||||||
|
@model_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def plural_model_name
|
||||||
|
@model_name.pluralize
|
||||||
|
end
|
||||||
|
|
||||||
|
def resource_name
|
||||||
|
@model_name.demodulize.underscore
|
||||||
|
end
|
||||||
|
|
||||||
|
def plural_resource_name
|
||||||
|
resource_name.pluralize
|
||||||
|
end
|
||||||
|
|
||||||
|
def name_columns
|
||||||
|
NAME_COLUMNS
|
||||||
|
end
|
||||||
|
|
||||||
|
def columns
|
||||||
|
begin
|
||||||
|
excluded_column_names = %w[id created_at updated_at]
|
||||||
|
@model_name.constantize.columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
|
||||||
|
rescue NoMethodError
|
||||||
|
begin
|
||||||
|
@model_name.constantize.fields.collect{|c| c[1]}.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type.to_s)}
|
||||||
|
rescue NoMethodError
|
||||||
|
# SimplyStored/CouchPotato
|
||||||
|
@model_name.constantize.properties.reject{|p| !(p.is_a?(CouchPotato::Persistence::SimpleProperty)) || p.name =~ /_ids?$/ || excluded_column_names.include?(p.name.to_s) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type.to_s)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def belongs_to_associations
|
||||||
|
#@model_name.constantize.properties.select{|p| p.is_a?(SimplyStored::Couch::BelongsTo::Property)}
|
||||||
|
associations= @model_name.constantize.properties.select{|p| p.is_a?(SimplyStored::Couch::BelongsTo::Property) && (p.options[:class_name].constantize.property_names & name_columns).any?}
|
||||||
|
for association in associations
|
||||||
|
def association.name_property
|
||||||
|
(options[:class_name].constantize.property_names & Bootstrap::Generators::ThemedGenerator::NAME_COLUMNS).first || :name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def extract_modules(name)
|
||||||
|
modules = name.include?('/') ? name.split('/') : name.split('::')
|
||||||
|
name = modules.pop
|
||||||
|
path = modules.map { |m| m.underscore }
|
||||||
|
file_path = (path + [name.underscore]).join('/')
|
||||||
|
nesting = modules.map { |m| m.camelize }.join('::')
|
||||||
|
[name, path, file_path, nesting, modules.size]
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_views
|
||||||
|
views = {
|
||||||
|
"index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"),
|
||||||
|
"new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"),
|
||||||
|
"edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"),
|
||||||
|
"#{form_builder}_form.html.#{ext}" => File.join('app/views', @controller_file_path, "_form.html.#{ext}"),
|
||||||
|
"show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")}
|
||||||
|
selected_views = views
|
||||||
|
options.engine == generate_erb(selected_views)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_erb(views)
|
||||||
|
views.each do |template_name, output_path|
|
||||||
|
template template_name, output_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def ext
|
||||||
|
::Rails.application.config.generators.options[:rails][:template_engine] || :erb
|
||||||
|
end
|
||||||
|
|
||||||
|
def form_builder
|
||||||
|
defined?(::SimpleForm) ? 'simple_form/' : ''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>The page you were looking for doesn't exist (404)</title>
|
||||||
|
<style type="text/css">
|
||||||
|
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||||
|
div.dialog {
|
||||||
|
width: 25em;
|
||||||
|
padding: 0 4em;
|
||||||
|
margin: 4em auto 0 auto;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-right-color: #999;
|
||||||
|
border-bottom-color: #999;
|
||||||
|
}
|
||||||
|
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- This file lives in public/404.html -->
|
||||||
|
<div class="dialog">
|
||||||
|
<h1>The page you were looking for doesn't exist.</h1>
|
||||||
|
<p>You may have mistyped the address or the page may have moved.</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>The change you wanted was rejected (422)</title>
|
||||||
|
<style type="text/css">
|
||||||
|
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||||
|
div.dialog {
|
||||||
|
width: 25em;
|
||||||
|
padding: 0 4em;
|
||||||
|
margin: 4em auto 0 auto;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-right-color: #999;
|
||||||
|
border-bottom-color: #999;
|
||||||
|
}
|
||||||
|
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- This file lives in public/422.html -->
|
||||||
|
<div class="dialog">
|
||||||
|
<h1>The change you wanted was rejected.</h1>
|
||||||
|
<p>Maybe you tried to change something you didn't have access to.</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>We're sorry, but something went wrong (500)</title>
|
||||||
|
<style type="text/css">
|
||||||
|
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||||
|
div.dialog {
|
||||||
|
width: 25em;
|
||||||
|
padding: 0 4em;
|
||||||
|
margin: 4em auto 0 auto;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-right-color: #999;
|
||||||
|
border-bottom-color: #999;
|
||||||
|
}
|
||||||
|
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- This file lives in public/500.html -->
|
||||||
|
<div class="dialog">
|
||||||
|
<h1>We're sorry, but something went wrong.</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user