
% rails generate scaffold post post:string% rails g scaffold --help config.generators do |g| # end RAILS_ROOT% rails console
puts $LOAD_PATH
...
...
... # controller.rb class <%= controller_class_name %>Controller < ApplicationController # GET <%= route_url %> # GET <%= route_url %>.xml def index @<%= plural_table_name %> = <%= orm_class.all(class_name) %> respond_to do |format| format.html # index.html.erb format.xml { render :xml => @<%= plural_table_name %> } end end ... # encoding: UTF-8 class <%= controller_class_name %>Controller < ApplicationController # GET <%= route_url %> def index @<%= plural_table_name %> = <%= class_name %>.paginate :page => params[:page], :order => 'id DESC' end ... # encoding: UTF-8 class PostsController < ApplicationController # GET /posts def index @posts = Post.paginate :page => params[:page], :order => 'id DESC' end ... # model.rb class <%= class_name %> < <%= parent_class_name.classify %> <% attributes.select {|attr| attr.reference? }.each do |attribute| -%> belongs_to :<%= attribute.name %> <% end -%> end # encoding: UTF-8 class <%= class_name %> < <%= parent_class_name.classify %> cattr_reader :per_page @@per_page = 20 <% attributes.select {|attr| attr.reference? }.each do |attribute| -%> belongs_to :<%= attribute.name %> <% end -%> end # encoding: UTF-8 class Post < ActiveRecord::Base cattr_reader :per_page @@per_page = 20 end gem 'haml-rails' #RAILS_ROOT/config/application.rb config.generators do |g| # rspec , , #.. spec's g.test_framework :rspec, :view_specs => false, :helper_specs => false, :routing_specs => false, :request_specs => false end #RAILS_ROOT/config/application.rb config.generators do |g| g.test_framework :rspec, :view_specs => false, :helper_specs => false, :routing_specs => false, :request_specs => false g.fixture_replacement :factory_girl, :dir => "spec/factories" end % rails g scaffold final final:string invoke active_record
create db / migrate / 20110713193843_create_finals.rb
create app / models / final.rb
invoke rspec
create spec / models / final_spec.rb
invoke factory_girl
create spec / factories / finals.rb
route resources: finals
invoke scaffold_controller
create app / controllers / finals_controller.rb
invoke haml
create app / views / finals
create app / views / finals / index.html.haml
create app / views / finals / edit.html.haml
create app / views / finals / show.html.haml
create app / views / finals / new.html.haml
create app / views / finals / _form.html.haml
invoke rspec
create spec / controllers / finals_controller_spec.rb
invoke helper
invoke rspec
invoke helper
create app / helpers / finals_helper.rb
invoke rspec
invoke stylesheets
identical public / stylesheets / scaffold.css Source: https://habr.com/ru/post/123551/
All Articles