顯示具有 RubyOnRails 標籤的文章。 顯示所有文章
顯示具有 RubyOnRails 標籤的文章。 顯示所有文章

2013年12月12日 星期四

[ROR] 後台建立 - 權限建立

這裡使用了 cancan這個有名的library

目標

1. 用 Device註冊帳號的初始帳號都是一般權限

2. 有一個網頁可以修改某個user為 admin的權限

3. 每個user都可以看某個頁面,但是因為權限不同而會不同



2013年12月9日 星期一

[ROR] 後台建立

目標:產生一個後台在 Heroku

讓同事能申請帳號,然後並手動加入admin的tag

在後台開一個admin的資料區塊,可以顯示同事上次替"神~清單"設定的簡易後台。



2013年11月4日 星期一

[ROR] rbenv and init initial env

看了一下

原本用 RVM 想說用一下 rbenv看看

緣由 因為原本自學的時是使用的是 2.0.0 + ROR 4.0
但是上次的一個前輩的建議 使用 1.9.3 + ROR 3.2.15 會比較多資源

因為想說之後也有可能會遇到多版本的問題
舊先學習看看

http://edapx.com/2013/05/23/switching-from-rvm-to-rbenv/

https://github.com/sstephenson/rbenv



2013年9月29日 星期日

[ROR] Turbolink, ajax, jQuery, coffeescript, Asset Pipeline

X  …. 怎麼那一次混雜那麼多東西orz
緣由:
想在ROR 4上面寫ajax
我先依照的教學寫了一下,
http://ihower.tw/rails3/assets-and-ajax.html
不過他是for ROR 3.x
所以惡夢就開始了...

2013年9月22日 星期日

[ROR] heroku change postgress

 

如果要清掉heroku上面的DB

好像沒辦法用 rake db:drop

我是直接用它的web介面刪掉db

在建立一個新的

不過

使用 git push heroku時

db帳號密碼就會不對

 

我後來找到  

heroku config

可以看到

DATABASE_URL:  xxxxx

HEROKU_POSTGRESQL_AQUA_URL:   yyyyyy

就用

heroku config:set DATABASE_URL=yyyyyy

換成正確的postgres db的位置就好了

 

2013年9月21日 星期六

[ROR] heroku, postgres,

有在嘗試的 Paas

heroku and openshift

原本在試驗openshift ,不過在上傳啟動server的部份遇到的困難,我就轉去heroku看看

 

基本上我照著他的教學跑了一次

有遇到幾個問題

1. 網頁上app 的名稱

似乎給了一串預設的編碼

如果改了

就要記得執行  

git config -e

把裡面的 git remote的位置改變

 

2. postgres 

他們官方是建議使用postgres 

我也在local端裝了

不過如過在 development 下 使用 postgres

會導致我必需把local 的username 給傳到git 上面

有點不想.... 實驗了很久,如果再mac 上在開一個使用者

好像還是有權限的問題

最後....我想說在development下用  sqlite就好了

Gemfile 寫下

 

# Use postgresql as the database for Active Record
group :production, :test do
gem 'pg'
end

group :development do
gem 'sqlite3'
end

 

 

然後

database.yml 就用

development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

 

 

 

==================

ROR 能做的設定參考:http://ihower.tw/rails3/environments-and-bundler.html

http://robdodson.me/blog/2012/04/27/how-to-setup-postgresql-for-rails-and-heroku/

http://www.fullybaked.co.uk/articles/getting-postgresql-running-on-osx-mountain-lion

http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/

 

2013年9月10日 星期二

[ROR] 閱讀筆記

1.  關於瀏覽器相容的問題

我原本以為都是前端語法的問題 (實際上也應該是吧?!)

不過ror 似乎有些config 可以幫忙設定讓產生的網頁能告訴瀏覽器要怎樣做....

Ref : http://ihower.tw/rails3/environments-and-bundler.html

config.action_dispatch.best_standards_support = : builtin

 

2. 

建立 model  :   rails g model price_log

之後對model(s)做變更   :   rails g migration add_price_log_parameters

產生  :   bundle exec rake db:migrate

想要試做 http://ihower.tw/rails3/activerecord-relationships.html

可是卻無法有效的在console下指令

ref : http://guides.rubyonrails.org/association_basics.html

 

 

 

3. 觀察log   : tail -f log/development.log

2013年8月26日 星期一

[ROR] Ruby

開始走向下一步

過去對於後台整合我常常有諸多意見

還是來實作看看

 

當然還是得要借助先輩的力量!

http://ihower.tw/rails3/firststep.html

http://ihower.tw/blog/archives/1720

 

http://www.cc.ntu.edu.tw/chinese/epaper/20070620_1007.htm

http://rails.pixnet.net/blog/post/22952893

 

https://www.ruby-toolbox.com/

 

簡介個方法

http://guides.ruby.tw/ruby/about.html

 

在 Wiki 中找到 Closure 的資料,其中有的一段 Ruby 程式碼清楚闡述了 Proc 和 Lambda的差別:

http://tonytonyjan.net/2011/08/12/ruby-block-proc-lambda/