2014年12月9日 星期二

problems on Rals - brew reinstall opensslRuby Bundle Symbol not found: _SSLv2_client_method (LoadError)


http://stackoverflow.com/questions/25492787/ruby-bundle-symbol-not-found-sslv2-client-method-loaderror
http://stackoverflow.com/questions/18521304/bundle-install-fails-error-loading-rubygems-plugin-after-i-deleted-files
http://stackoverflow.com/questions/19262312/installing-pg-gem-failure-to-build-native-extension/19620569#19620569

rvm get stable
rvm reinstall ruby-1.9.3-p545 (got the latest version)

brew reinstall openssl

  • Install another build of Xcode Tools (typing 'brew update' in the terminal will prompt you to update the Xcode build tools)
  • brew update
  • brew install postgresql

2014年11月26日 星期三

godaddy + heroku

http://lifesforlearning.com/heroku-with-godaddy/

heoroku domains:add www.example.com
heroku domains:add example.com

log in to godaddy

  1. Then remove all records here except for the NameServers
  2. Add / edit the CNAME record for “www” to point to your Heroku app domain name like “example.herokuapp.com”. Mine is madpad.herokuapp.com.

2014年11月22日 星期六

elasticsearch + searchkick


https://intercityup.com/blog/installing-elasticsearch-mac-os-x-10-9-mavericks-development/


point $JAVA_HOME to the Java installation path in your .bash_profile:
export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"

brew install elasticsearch


And start elasticsearch with:
elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml




https://shellycloud.com/blog/2013/10/adding-search-and-autocomplete-to-a-rails-app-with-elasticsearch

# Gemfile
gem "searchkick"
After running bundle install, we can configure the Book model to be searchable:
# app/models/book.rb
class Book < ActiveRecord::Base
  searchkick
  # ...
end
Next, we need to build the index for the Book class so that the books we already have in the database will be added to Elasticsearch. When new records are created rebuilding isn't necessary, but you have to do it whenever you change the searchkick method in your model:
rake searchkick:reindex CLASS=Book

https://github.com/ankane/searchkick

Deployment

Searchkick uses ENV["ELASTICSEARCH_URL"] for the Elasticsearch server. This defaults tohttp://localhost:9200.

Heroku

Choose an add-on: SearchBoxBonsai, or Found.
# SearchBox
heroku addons:add searchbox:starter
heroku config:add ELASTICSEARCH_URL=`heroku config:get SEARCHBOX_URL`

# Bonsai
heroku addons:add bonsai
heroku config:add ELASTICSEARCH_URL=`heroku config:get BONSAI_URL`

# Found
heroku addons:add foundelasticsearch
heroku config:add ELASTICSEARCH_URL=`heroku config:get FOUNDELASTICSEARCH_URL`
Then deploy and reindex:
heroku run rake searchkick:reindex CLASS=MODEL


2014年11月18日 星期二

sloving the problem while using turbolinks in RoR app which make facebook script not loading

http://reed.github.io/turbolinks-compatibility/facebook.html

Official Implementation

HTML<body>
  <div id="fb-root"></div>
  <script>
    (function(d, s, id){
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
  </script>

  <!-- Like button -->
  <div class="fb-like" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true"></div>
</body>

Solution

Remove the script from the body and load the following script inside the <head>.
add the script below to js.coffee  file
COFFEESCRIPTfb_root = null
fb_events_bound = false

$ ->
  loadFacebookSDK()
  bindFacebookEvents() unless fb_events_bound

bindFacebookEvents = ->
  $(document)
    .on('page:fetch', saveFacebookRoot)
    .on('page:change', restoreFacebookRoot)
    .on('page:load', ->
      FB?.XFBML.parse()
    )
  fb_events_bound = true

saveFacebookRoot = ->
  fb_root = $('#fb-root').detach()

restoreFacebookRoot = ->
  if $('#fb-root').length > 0
    $('#fb-root').replaceWith fb_root
  else
    $('body').append fb_root

loadFacebookSDK = ->
  window.fbAsyncInit = initializeFacebookSDK
  $.getScript("//connect.facebook.net/en_US/all.js#xfbml=1")

initializeFacebookSDK = ->
  FB.init
    appId     : 'YOUR_APP_ID'
    channelUrl: '//WWW.YOUR_DOMAIN.COM/channel.html'
    status    : true
    cookie    : true
    xfbml     : true

2014年11月17日 星期一

font awesome on website and assets precompile setting

/assets/stylesheets/application.css
     @import "bootstrap-sprockets";
     @import "bootstrap";


/config/environments/ production.rb
  config.assets.compile = true

  config.serve_static_assets = true

/config/application.rb
   config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
    config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
    config.assets.precompile += %w(.svg .eot .woff .ttf)
    config.assets.paths << "#{Rails}/vendor/assets/fonts"



run

rake assets:precompile rails_ENV=production

2014年11月13日 星期四

Rails 4 OmniAuth using Devise facebook

http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/#changes

2014年11月11日 星期二

setup SSL on Heroku for a Rails Application

https://www.resumonk.com/blog/setup-ssl-certificate-heroku/



config/enviroment/production.rb
set
config.force_ssl = true

2014年10月31日 星期五

github branch co-work

create a new branch from the branch develop

$ git checkout -b myFeature dev
Creates MyFeature branch off dev. Do your work and then
$ git commit -am "Your message"
Now merge your changes to dev without a fast-forward
$ git checkout dev
$ git merge --no-ff myFeature
edit
Now push changes to the server
$ git push origin dev
$ git push origin myFeature



http://stackoverflow.com/questions/20101994/git-pull-from-master-into-the-development-branch

git pull from master into the development branch


git checkout dmgr2      # gets you "on branch dmgr2"
git fetch origin        # gets you up to date with origin
git merge origin/master



conflict 修改完後
git add [file]
git commit


取消已暫存的檔案

git reset HEAD <file>
看目前的 branch 與其他 branch 有哪些差異,你可以使用 git diff 的指令去觀察,例如我現在想要看 master 跟 cat 這兩個 branch 的差異,我只要下:
$ git diff cat master

2014年10月22日 星期三

setting local server on yosemite

http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/


to start it
sudo apachectl start
to stop it
sudo apachectl stop
to restart it
sudo apachectl restart
To find the Apache version
httpd -v
cd /etc/apache2/users
sudo nano username.conf
Then add the content below swapping in your ‘username’ in the code below:


Permissions on the file should be: permission checking ls -la
-rw-r--r--   1 root  wheel  298 Jun 28 16:47 username.conf
If not you need to change…
sudo chmod 644 username.conf
sudo nano /etc/apache2/httpd.conf
And make sure these 3 modules are uncommented (the first 2 should be on a clean install):
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
And also uncomment this configuration file also in httpd.conf
Include /private/etc/apache2/extra/httpd-userdir.conf
Then open another Apache config file and uncomment another file:
sudo nano /etc/apache2/extra/httpd-userdir.conf
And uncomment:
Include /private/etc/apache2/users/*.conf
Restart Apache for the new file to be read:
sudo apachectl restart

2014年10月21日 星期二

RoR setting ref.

安裝可以參考下面兩個網頁

https://www.railstutorial.org/book/beginning
看 1.1 1.2 即可

https://github.com/rocodev/guides/wiki/setup-mac-development
只需要這幾個就可 系統套件 安裝 XQuartz ImageMagick / MySQL 安裝 RVM 與 Ruby 2.0



get repo. from github for ror
>git clone git@github.com:Project/project.git [A public project of github]
->cd project
->bundle install
->rake db:migrate
->rails server

2014年9月13日 星期六

ckeditor setting

http://terrybu.blogspot.com/2014/07/getting-ckeditor-to-work-on-your-rails.html

 Go to your production.rb under config and set   config.serve_static_assets = true

add the  follow script to _form.html.erb

<script type='text/javascript' charset='UTF-8'>
  $(document).ready(function(){
    $('form[data-remote]').bind('ajax:before', function(){
      for (instance in CKEDITOR.instances){
        CKEDITOR.instances[instance].updateElement();
      }
    });
  });
</script>


also add
  <script type="text/javascript">
    var CKEDITOR_BASEPATH = '/assets/ckeditor/';
  </script>


add to config/application.rb

config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
config.assets.precompile += Ckeditor.assets
config.assets.precompile += %w(ckeditor/*)

in the first of application.html



Media Embedding with CKEditor + Rails 4.0
https://rjsteen.wordpress.com/2014/01/06/media-embedding-with-ckeditor-rails-4-0/

*do precompile to see the changes



Create config.js in public/assets/ckeditor/config.js

for mini toolbar and mediaembed

add //= require ckeditor/config in application.js

and raw for showing content of the ckeditor ex: <%= raw article.content %>


** gotta override config,js in new folder under javascript/ckeditor

it wont be changed in public/assets/ckeditor/config.js, when deploy to Heroku.