2015/05/10 快吐死!!被搞死!!
突然有一天,發現不能運作,查了老半天,發現是activerecord好像不能運作,但明明程式沒改,自行就不能連了…….
解決方式:請在database.yml 補上 socket: /tmp/mysql.sock
http://stackoverflow.com/questions/5499035/ruby-on-rails-3-cant-connect-to-local-mysql-server-through-socket-tmp-mysql-s
為何要這樣?不能理解,有人能告訴我嗎?
另外
用排程 Cron Jobs,每三十分鐘 touch ~/rails_apps/xxxxxxxxx/tmp/restart.txt
因為 有時候它會自動停止運作!
2014/08/21
====justhost===
第一步:先按官方的做
https://my.justhost.com/hosting/help/rails
重點一:請加subdomain,然後home目錄會有subdomain目錄,砍了,改成用ln,詳細請參考上面官方範例。記得做完要多確定路徑。
重點二:記得因為是用passenger,所以要在你的rails_app/xxxapp目錄下,建立兩個目錄:public和tmp目錄,tmp目錄下放restart.txt;
public不用管,上網查,只是passenger用
tmp很重要,你上傳更新後,要用ssh登入到app目錄下,執行touch ./tmp/restart.txt 這樣等五秒,更新的程式才會更新
如果覺得麻煩,可以放always_restart.txt,執行一次以後,就每次都會更新;取消方式,把檔案刪除即可。
重點三:請把.htaccess檔案放到public目錄,這超級重要!!
其它按上面的官方說明,把它做完就行了!
====sinatra=====
底下網站參考和準備
http://www.danneu.com/posts/15-a-simple-blog-with-sinatra-and-active-record-some-useful-tools/
http://stackoverflow.com/questions/16683903/sinatra-mysql-and-activerecord
http://www.sinatrarb.com/intro.html
http://qiita.com/u1_fukui/items/88c10d4d530ec6fbaaa1
http://recipes.sinatrarb.com/p/models/active_record
底下檔案放在同一個目錄底下:
1. Gemfile
# Gemfile
source :rubygems
gem “sinatra”
gem “activerecord”
gem “mysql2”
gem “shotgun” –這無用**開發測試有用
gem “tux” –超重要,但只限一開始,db確定連上就沒什麼用,但可以做db操作 **開發測試用
bundle install
2. database.yml 填一填
production:
adapter: mysql2
database:
host: localhost
username:
password:
http://www.sinatrarb.com/faq.html
require 'sinatra' helpers do def protected! return if authorized? headers['WWW-Authenticate'] = 'Basic realm="Restricted Area"' halt 401, "Not authorized\n" end def authorized? @auth ||= Rack::Auth::Basic::Request.new(request.env) @auth.provided? and @auth.basic? and @auth.credentials and @auth.credentials == ['admin', 'admin'] end end get '/' do "Everybody can see this page" end get '/protected' do protected! "Welcome, authenticated client" end LOGIN FORM (GET LOGIN METHOD) <form method="post" action="/login"> <p><label>Username</label><input name="post[username]" /></p> <p><label>Password</label><input name="post[password]" type="password"/></p> <p><button type="submit">Login</button></p> </form> POST LOGIN METHOD post '/login' do if authenticate(params["post"]["username"], Digest::MD5.
https://gauntface.com/blog/2014/02/05/cordova-web-best-practices-v2-0
http://spiritmachineblog.tumblr.com/post/41432461669/a-simple-openlayers-app-with-yeoman-sinatra-mongodb
HTML5 Boilerplate Sass with Compass Modernizr
http://thibaultdenizet.com/tutorial/cors-with-angular-js-and-sinatra/ 簡單說:發現現在要走moble app,要有yoeman的產生的網頁檔,或是 走Angular.js, jquerymobile, bootstrap三個來做。
新增、修改、刪除 走Restful,看上面範例。這樣產出來的網頁能適用 手機和平板。
但要把 程式轉成可以用cordova,要用Compass之類的,把所有的js, css, html5 三個檔。 http://vimeo.com/35998909
https://www.youtube.com/watch?v=e4yUTkva_FM
https://www.youtube.com/watch?v=wVntVkRLR3M
bit.ly/zen-ng-phonegap
Angular UI部份
這看起來有點像官方Angular原生 http://angular-ui.github.io/bootstrap/
這是另一個整合好Bootstrap and Angular JS http://mobileangularui.com/
這是angular+ionic http://ionicframework.com/ http://ionicframework.com/docs/overview/#download http://ionicframework.com/docs/components/
================== **SASS (Sass)
**require jquery.mobile 21:13
http://demos.jquerymobile.com/1.2.0/ http://demos.jquerymobile.com/1.2.0/docs/pages/page-anatomy.html
css style => data-role
%meta{name: ‘viewport’, content: ‘width=device-width, initial-scal-1’)
http://demos.jquerymobile.com/1.2.0/docs/lists/lists-collapsible.html
**haml http://html2haml.heroku.com/
===== phonegap 41:01 開一個android專案,但只是把網頁load進來…..真是簡單 www/index.html
script include: phonegap-1.3.0.js onBodyLoad(){ document.addEventListener(“dviceready”, onDeviceready, false); windows.