2017年3月22日 星期三

Installation of Laravel Valet

after you install homebrew

composer global require "laravel/installer=~1.1"

brew update

brew install homebrew/php/php71

composer global require laravel/valet

cd ~

ls -la

looking for .bashrc

open ~/.bashrc

source ~/.bashrc

make sure you add the new path successfu
echo $PATH

valet install

ping *.dev




Installation of Composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

2017年3月17日 星期五

little rails project

type>brand>size>products details

entroll date
entroll time
customer ID
customer gender
customer birthday
customer email
customer address
customer TAX
payment method
delivery


customer ID
modifydate
modifytime
order No
product bran No
product brand Name
product No
product name
product type
product quantity
remark

2017年3月2日 星期四

安裝RVM

參考資料:
http://rvm.io/

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3


\curl -sSL https://get.rvm.io | bash -s stable

2017年3月1日 星期三

Rails Command Line

參考資料:
http://guides.rubyonrails.org/command_line.html

Rails 筆記

 參考資料:Ruby on Rails實戰聖經

//外卡路由 config/routes.rb
match ':controller(/:action(/:id(.:format)))', :via => :all

//資料驗證ActiveRecord Validation app/models/event.rb
class Event < ActiveRecord::Base
    validates_presence_of :name #field name
end

//分頁模組 add the following in Gemfile
gem "kaminari"
controller:
@events = Event.page(params[:page]).per(5)
view:
<%= paginate @events %>

//show message
add it at app/views/layouts/application.html.erb before yield
<p style="color: green"><%= flash[:notice] %></p>
controller:
flash[:notice] = "completed"

//The diffirences between render & redirect_to
render:回傳action樣板,而不是重新導入action
redirect_to:重新導入action

//before_action
before_action :set_event, :only => [ :show, :edit, :update, :destroy]
def set_event
  @event = Event.find(params[:id])
end
action建議封裝,放在private or protected中

//Partial template
view檔案以"_"開頭,for example _form.html.erb
<%= render :partial => 'form', :locals => { :f => f } %>

//RESTful參數
event_path(@event)需要參數,根據HTTP動詞決定show、update、destroy
events_path毋需參數,根據HTTP動詞決定index、create