楽天APIを用いたECサイト風のサイト(購入機能はなし)
ruby (2.5.0)
rails (5.1.7)
'devise' # ログイン機能
'rails_admin' # 管理者画面
'cancancan' # 管理者権限
'dotenv-rails' # 環境変数管理
'rakuten_web_service' # 楽天API
楽天APIを使ったECサイト風サイト
rails g devise User
rails db:migrate
gem 'rails_admin'
gem 'cancancan'
bundle install
rails g rails_admin:install
rails g cancan:ability
users
テーブルにadmin
カラムを追加admin
カラムにtrue
を代入rails g model Want --parent=Ownership
has_many :wants
has_many :want_items, through: :wants, source: :item
want
, unwant
, want?
has_many :wants
has_many :want_users, through: :wants, source: :user
resources :items, only: [:show, :new]
resources :ownerships, only: [:create, :destroy]
rails g controller ownerships create destroy
rails g model Cart --parent=Ownership
has_many :carts
has_many :cart_items, through: :carts, source: :item
cart
, uncart
, cart?
has_many :carts
has_many :cart_users, through: :carts, source: :user
get 'users/:id/cart', to: 'users#cart', as: 'cart'
rails g model ownership type:string user:references item:references
t.index [:user_id, :item_id , :type], unique: true
rails db:migrate
belongs_to :user
belongs_to :item
has_many :ownerships
has_many :items, through: :ownerships
has_many :ownerships
has_many :users, through: :ownerships
resources :users, only: [:show]
rails g controller users show
show
にはユーザ詳細を表示show
, logout
のリンクを表示user_signed_in?
やcurrent_user
を活用
gem 'rakuten_web_service'
bundle install
gem 'dotenv-rails'
bundle install
RAKUTEN_APPLICATION_ID
を記入rails g model item code:string name:string url:string image_url:string
rails db:migrate
presence: true, length: { maximum: 255 }
resources :items, only: [:new]
rails g controller items new
rails g migration AddNameToUsers name:string
rails db:migrate
configure_permitted_parameters
メソッドgem 'devise'
bundle install
rails g devise:install
rails g devise:views
)rails new
mysql.server start
rails db:create
root to: 'toppages#index'
rails g controller toppages index
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.