'1.0.0.rc1' gem 'hanami-model', '~> 1.0.0.rc1' gem 'pg' group :development do # Code reloading # See: http://hanamirb.org/guides/projects/code-reloading gem 'shotgun' end group :test, :development do gem 'dotenv', '~> 2.0' end
module Web class Application < Hanami::Application configure do ## # BASIC # # Define the root path of this application. # All paths specified in this configuration are relative to path below. # root __dir__ # Relative load paths where this application will recursively load the
as: :home get '/books/:id', to: 'books#show' resources :books resources :books, only: [:new, :create, :show] resources :books, except: [:index, :edit, :update, :destroy] namespace 'docs' do get '/installation', to: 'docs#installation' get '/usage', to: 'docs#usage' end Railsのroutingの書き方に大分近い
%></h1> # apps/web/views/dashboard/index.rb module Web::Views::Dashboard class Index include Web::View def title 'Dashboard' end end end 当然controllerで定義する事も可能だが、"expose"が必 要 + 変数しか使えない
primary_key :id column :name, String, null: false column :created_at, DateTime, null: false column :updated_at, DateTime, null: false end end end # db/migrations/20170402002500_create_todos.rb Hanami::Model.migration do change do create_table :todos do
Manage assets hanami console # Starts a hanami console hanami db [SUBCOMMAND] # Manage set of DB operations hanami destroy [SUBCOMMAND] # Destroy hanami classes hanami generate [SUBCOMMAND] # Generate hanami classes hanami help [COMMAND] # Describe available commands or one specifi hanami new PROJECT_NAME # Generate a new hanami project hanami rackserver # [private] hanami routes # Prints the routes hanami server # Starts a hanami server hanami version # Prints hanami version
end end configure :production do assets do fingerprint true end end ... <%= javascript 'application' %> # => <script src="/assets/application-d1829dc353b734e3adc24855693b70f9.js" <%= stylesheet 'application' %> # => <link href="/assets/application-d1829dc353b734e3adc24855693b70f9.css"