Coder Social home page Coder Social logo

ama's Issues

想請教一下幾個問題。

  1. 實例變數如果放在 layouts/application.html.erb 裡,是否每個controller都要引用?
  2. 什麼情況下,只需要有model 而不需要controller 和 view?
  3. Google 的網站分析程式,應該放在哪?假設我有多個 layout,可以統一放在 app/assets/javascripts/application.js 裡面嗎? 還是只能一個一個放在 layouts/*.html.erb 裡?
    2015-10-16 09 07 31
  4. 如果我有多個controllers想共用上傳照片模組,是否就一定要使用 Polymorphic Association?
  5. 依照Rails101s的範例,一個group對多個posts,如果我不想用按 New post 去新增,而直接把 post new 表單塞在 group 的 show視圖下,實做可以成功,但是資料驗證會失敗,想請教一下該如何修改?
    2015-10-16 09 20 24

[分享] 強制關閉 Rails server 的方法

If your Rails server is stuck. You can run the following commands:

$ rm /your_project_path/tmp/pids/server.pid
$ ps -aef | grep rails
$ lsof -wni tcp:3000
$ kill -9 the_pId_number

想請問關於後端資料庫的選用原則或考量?

小弟初學Rails,沒有什麼程式底子,看了幾套教材,
而不同教材之間選用做示範的資料庫,都會有點不太一樣,但我還是感受不出來,選用的資料庫到底在整個專案,起了什麼作用。
所以想請問各位大大,Rails本身內建Sqlite,其他也還有MySQL、PostgreSQL、Redis 等等
但當在開發專案實際上線的時候,選用資料庫種類時,其中比較重要的原則有哪些?
可靠度?存放的檔案型態?存取速度?

小弟自己在網路上有看到這篇MySQL 與 PostgreSQL的比較文,
http://codex.wiki/post/146792-816
也希望有善心人士有相關的資料是否可以讓小弟知道,解解求知慾,感謝各位!!

請教一下,推薦的Bootstrap 3 + Font-awesome 應該如何設定?

如題。我目前是使用 Rails 4.2.0 + Ruby 2.2.0

gem 'twitter-bootstrap-rails'
gem 'twitter-bootswatch-rails'
gem 'twitter-bootswatch-rails-helpers'
gem 'font-awesome-rails'

但是圖庫字體好像無法使用,我的 app/assets/stylesheets/application.css 設定如下:

 *      
 *= require_self
 *= require spacelab/loader   
 *= require spacelab/bootswatch
 *= require font-awesome      
 *= require rails_bootstrap_forms
 */ 

另外 app/assets/stylesheets/bootstrap_and_overrides.css.less 設定如下:

@import "twitter/bootstrap/bootstrap";

// Set the correct sprite paths
@iconSpritePath: image-url("twitter/bootstrap/glyphicons-halflings.png");
@iconWhiteSpritePath: image-url("twitter/bootstrap/glyphicons-halflings-white.png");

// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
@fontAwesomeEotPath: font-url("fontawesome-webfont.eot");
@fontAwesomeEotPath_iefix: font-url("fontawesome-webfont.eot?#iefix");
@fontAwesomeWoffPath: font-url("fontawesome-webfont.woff");
@fontAwesomeTtfPath: font-url("fontawesome-webfont.ttf");
@fontAwesomeSvgPath: font-url("fontawesome-webfont.svg#fontawesomeregular");

// Font Awesome
@import "fontawesome/font-awesome";

// Glyphicons
//@import "twitter/bootstrap/glyphicons.less";

// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation
//
// Example:
// @link-color: #ff0000;                                                                                                                                                  

~

我都沒有改,但是就是無法Work >"><

共用method應該寫在哪裡

我有多個Background Job,分別處理不同的工作,但是在工作處理完成後都會回傳處理結果,所以我就想要寫一個共用method,讓各個Job可以呼叫同一個method,但是我想不出來可以寫在哪?寫在application_controller似乎不是很好,請問有人可以提點一下嗎?謝謝

想請教一下 Rails 4.2 的環境參數設定

RAILS 4.2把一些關鍵參數設定為 <%= ENV['DATABASE_PASSWORD'] %>
<%= ENV['DATABASE_URL'] %>... 之類的,究竟應該設定在哪裡?

以 Ubuntu Desktop 為例,是不是設定在 ~/.bashrc 底下?
就直接下 DATABASE_PASSWORD = '123456'

在 Mac OS 上面用 git 換 email 的問題

大家好,我碰到一個 git client 中邪的問題。
環境是 mac os

我在 heroku 上面的帳號是 [email protected] ,我想要 push 到 heroku 上面。
我一開始是用 [email protected] 做為我的 git email
可是我想要換成 [email protected] ,但是當我 push 的時候卻一直和我說是 舊的那個帳號。
請問大家有解嗎?

註1:我有重開 shell 和 重開機 過,還是一樣。
註2:我的heroku 確定有加入 ssh public key

git config --global user.email "[email protected]"
git config -l
=> user.name=puff-tw
=> [email protected]

heroku logout
=>  Local credentials cleared.

heroku login
=> Enter your Heroku credentials.
=> Email: [email protected]
=> Password (typing will be hidden):
=> Logged in as [email protected]

git push production master
=>  !  Your account [email protected] does not have access
=>  !
 => !  SSH Key Fingerprint: 96:77:5c:4e:76:08:cc:e7:4d:19:60:25:66:dd:20:f0

=> fatal: Could not read from remote repository.

=> Please make sure you have the correct access rights
=> and the repository exists.

dataTables沒辦法work

我有哪個部份做錯了嗎?謝謝
Rails version 4.2.3
jquery-datatables-rails 3.3.0

application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap/dropdown
//= require bootstrap/alert
//= require dataTables/jquery.dataTables
//= require_tree .

application.css.scss

/*
 *= require dataTables/jquery.dataTables
 *= require_tree .
 *= require_self
 */
 @import "bootstrap-sprockets";
 @import "bootstrap";

customers.coffee

jQuery ->
    $('#customers').dataTable

index.html.erb

<table id="customers" class="table">
  <thead>
.......
  </thead>
  <tbody>
    <% @customers.each do |customer| %>
.........
    <% end %>
  </tbody>
</table>
<%= paginate @customers %>

RSpec view 錯誤 controller response 問題

想請教一下,在寫 rspec controller 測試時,寫好 response 200
跑測試時也沒有問題,但實際上在view有錯誤,所以頁面其實是 response 500
但 controller 沒有測試到,請問一下這是正常的嗎?該如何測試出view的錯誤?

Model建立Person,卻產生people檔案

I build the model name call "Person". And then the rails will auto-generated person's file.
Unfortunately, I have two files name call "people". I don't understand what happened.
發生有點吊詭的事,就是建立名字叫Person的Model。
正常來說應該是person的檔案,但是rails會自動幫我生出兩個地方叫做"people"的檔案。

$ rails g model Person name:text parent_id:integer parent_type
invoke active_record
create db/migrate/20150926161949_create_people.rb <------------------------ file name of people
create app/models/person.rb
invoke test_unit
create test/models/person_test.rb
create test/fixtures/people.yml <------------------------------------------------------- file name of people

Ruby 作業求救

不好意思沒有注意到這個問題違規到了 Coursera 的 Honor Code, 因此這個問題已被關閉. 謝謝!


哈囉, 我想要請求一個有點大的協助 😭😭, 我在 Coursera 上上 Rails, 第一份 Ruby 作業我就遇到困難了, 想要拜託高手協助!! 題目是 “找出文檔中出現頻率最高的字”, 指示:

1. 讀取一份有三行字的 test.txt 文檔
2. 找出每一行中出現頻率最高的字
3. 比較這三行中 "出現頻率最高的字" 的數量, 找出最大的, 那即是整份文檔中 "出現頻率最高的字”

感激不盡!!!!!

dataTables沒辦法正常work part2

Follow up of #28.

多虧@bih00425的幫忙,讓dataTables總算可以正常顯示,但是一波未平一波又起,又有了新問題,dataTables的jQuery在page每次開啟時都沒有work,需要我做reload page後效果才會正常。

Page reload before
image

Page reload after
image

version mismatch "spring"

如何發生:
我在下rails d model Person 這行指令,產生下面這個問題

問題:
There is a version mismatch between the spring client and the server.
You should restart the server and make sure to use the same version.

CLIENT: 1.4.0, SERVER: 1.3.6

關於資料間 Association 設計疑問

大家好,是最近踏入ror的新手,
想請教一個資料庫設計上的疑問,疑問如下:

 假設我有一個資料表Companies,我想於此表中有聯絡人與負責人欄位,
 而聯絡人與負責人所提供的資訊屬性( name, phone, address ... etc)一樣,
 所以我想由資料表Accounts作提供,這麼一來,我認為得關係如下嗎?
 Company has_many Accounts,Account belongs_to Company

實作後的結果跟我想要的結果不太一樣,且腦袋有點卡住了,
第一次發問如果有什麼沒注意到的地方,請大家多多包涵!
 

請問相同Model內的雙層has_many要如何實作?

如題,請問如何定義childrengrandchildren兩個methods,在同一個Person model內讀取關連?

# Create a "Person" model that allows a “children” method as below.
tom = Person.create(name: "Tom")
Person.create(name: "May", parent: tom)
Person.create(name: "Syd", parent: tom)

tom.children.map(&:name)
#=> ["Syd", "May"]
# Furthermore, how to implement a "grandchildren" method as below?
Person.create(name: "Wen", parent: syd)
Person.create(name: "Jon", parent: may)

tom.grandchildren.map(&:name)
#=> ["Wen", "Jon"]

出處:原Gist檔案

How to find a good remote job?

Hi Juanito, really appreciate your generosity. I have a question in job searching. I heard that you're currently working remotely, so I would like to ask how to find a good remote job?

This question contains two aspects:

  1. I believe only few companies in Taiwan are willing to hire a remote developer. That's not the culture. So how do you know there are companies that are looking for remote developers (either domestic or foreign companies) ?
  2. Working remotely means the employers' trust in one's attitude and ability. If you're hiring a remote developer for your company, what qualities or skills do you expect from a candidate (as a Rails developer or system operator) ?

I will be very grateful if you are willing to answer them all; however, any advice will be appreciated. Thanks!

SPA session auth management

目前用正在玩 React 做 SPA,但遇到了登入和驗證的問題

想請問在無後端 template render 的情況下,如何做到 session 和 auth management? 😟

目前想到最簡單的方法是每次請求都向 server 驗證,好像太沒效率了 😕

想請教一下,如果我想讓表單有兩種不同的選擇內容,應該怎麼做?

如題,我想寫一個房仲網站,例如有房屋和土地兩種項目,這個檔案在 app/views/items/_form.html.erb

<%= f.select :kind, [['房屋',0],['土地',1]], include_blank: true, label: '項目' %>
<%= f.select :category, [['大廈',0],['透天',1],['公寓',2],['建地',3'],['農地',4],['工業地',5]], label: '分類' %>

當『新增』物件時,我希望選完項目後,若選擇『房屋』時可以只出現房屋的分類 (例:大廈、透天、公寓),選『土地』時可以只出現土地的分類(例:建地、農地、工業地)。

請問該如何修改?是否一定要搭配 jQuery 的 append?

會變動的設定值紀錄有沒有好的寫法?

嗨,大家好

之前寫rails的時候,有些全站的設定值我會開一個table,例如叫做settings去紀錄他
例如說,我寫一個購物的網站,後台有個欄位叫做 user_initial_cash,
紀錄說現在user如果開新帳號,有沒有贈送的代幣
而user_initial_cash_value則是紀錄如果有要贈送代幣,新帳號裡面的代幣要送多少

create_table "settings", force: :cascade do |t|
    t.integer  "user_initial_cash_value"
    t.boolean   "user_initial_cash"
end

而管理者可以進入後台依照需求更改
但是這個table就會永遠只有一個row(因為只有一個設定),覺得很奇怪,很不環保
所以想請問大家有沒有更好的寫法? 謝謝

請問怎麼做一個與Android app連結的Ruby on rails

目前有建置一個用android studio開發的APP
之前採用app →web→mysql
但連線上的安全性以及完整性出現問題
想改成
app→ruby on rails(mysql)
請問有哪個大大有經驗或者願意指導小弟
謝謝您
Blake

如何移除多餘的ruby

我在GitHub上抓了一個範例,下載回來後執行bundle install,結果在環境中造成了有兩套ruby,使得現在沒辦法建立新的專案。

kenny@test /usr/local/bin $ which -a ruby
/usr/local/bin/ruby
/usr/bin/ruby

痛苦的是我的環境當初是土法煉鋼的,根本沒想到要去裝RVM,現在後悔莫及。
請問我該如何移除掉/usr/local/bin/ruby呢?

關於 Ubuntu 14.04 使用 sublime text2 出現錯誤訊息

如題我每次開啟sublime都會一直跑以下error:
(sublime_text:2627): GLib-CRITICAL **: Source ID 2835 was not found when attempting to remove it
上網查一下好像可以不用理他,但是很礙眼啊~請問該怎麼讓他消失呢?
還是各位覺得我直接換sublime text3比較好 XD

另外好奇大家都習慣用什麼編輯器呢?
希望可以分享一下心得、優缺點 XD

Mobile App UI 設計問題

例如要設計一個 App 的界面,希望這個界面可以在 iOS 跟 Android 系統上都長一樣。

會用哪個尺寸開始設計,以及怎麼去適應到其他尺寸,並出圖給工程師。

謝謝!

rails enum 問題

請問資料欄位如:已完成、處理中、已拒絕
欄位型態通常會如何建立?使用integer,再搭配 rails 中的 enum嗎?
但使用過幾次,感覺不是很順,像是 where搜尋時是使用數字; 翻譯時也比較麻煩,有時候懶得翻譯乾脆使用中文時,跟simple form 搭配時又有 simple form產生出來的 radio id 問題
想請問有更好的解法嗎?或者只是我不熟enum的用法而已,謝謝

如何在 Ubuntu 14.04 使用 Nginx + Passenger 部署 rails app ?

目前自己嘗試..我先執行了以下指令:

sudo gem install bundler passenger --no-ri --no-rdoc
sudo apt-get install libcurl4-openssl-dev
sudo passenger-install-nginx-module
wget -O init-deb.sh http://www.linode.com/docs/assets/1139-init-deb.sh
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults

然後這時 server start 是成功的。

接著我將 /opt/nginx/conf/nginx.conf 編輯如下圖:
deploy4
並執行:

chmod g+x,o+x /home/rails/deploy/fishing
RAILS_ENV=production rake db:create
RAILS_ENV=production rake db:migrate

最後 restart server..網頁顯示結果如下圖:
deploy

至於 /opt/nginx/logs/error.log 記錄錯誤如下:
deploy2
deploy3

請問這是什麼問題? 我有哪裡要改進的嗎?

請問簡訊服務TWSMS的使用方式?

TWSMS簡訊:
https://github.com/xdite/twsms/blob/master/lib/twsms.rb

這是一個Module,首先應該放在 lib 底下,接著是要 require 還是不需要?(Auto-loading?)

我也有搜尋到是直接放在Gemfile 裡,像是 gem 'TWSMS',但是文件並不齊全。

另外帳號密碼要放在哪各位置?因為前兩行是,我記得 initialize 本來就會自動載入。

 def initialize(username, password)
    @uname, @upwd = username, password

最後是這個模組需要改寫嗎?因為是6年前的程式,有沒有需要改變的地方? Thx

mac terminal 尋找檔案、顯示檔案命令請益

大家好,小弟新手剛從linux跳到mac,也正想從sublime跳到vim,正在習慣中。
看到幾個個人很喜歡的工作方式,但不知道怎麼用,想請教各位前輩。

https://youtu.be/SOi_1reKn8M?t=9m15s
這段影片中講者輸入
((detached form ee1d824))$ e
就跳到了一個可以即時搜尋檔案的畫面

另外在11:53處
https://youtu.be/SOi_1reKn8M?t=11m53s
講者可以將檔案分別顯示在螢幕的左右各半

請問這兩個功能是需要安裝什麼套件嗎?

如何獲得Job 回傳值

我使用sidekiq來處理大批量資料轉入的job,但我想要知道有辦法可以獲得job處理完成的回傳值,像是處理資料總筆數與成功筆數嗎?謝謝幫忙

請問大家開發上切換視窗和目錄都是用什麼工具或快捷鍵

不確定發在這合不合適,發這篇主要是想, Rails 開發上很常做視窗切換(瀏覽器、終端機、文字編輯器)和文字編輯檔案目錄之間的切換,因為這太常做了,所以如果可以把這動作降低到平均兩三秒內或甚至一秒內,對效率的提升會很有助益,而不是一直 cmd + tab 或看目錄找檔案...,希望大家可以提出自己的「快速切換祕技」互相交流,甚至看了別人的做法後可以改進自己的快捷鍵組合技 😄

我的快捷鍵組合其實不多(所以才想向大家討教...),目前使用 chrome + iTerm2 + macvim

iTerm2 本身有提供 system-wide hotkey 設定,我設定 shift + space ,自從用了這個之後要切換到終端就無腦多了,我習慣用左手小拇指 + 大拇指按,剛好這組合要按也很方便,不會姿勢卡卡的感覺,這設定缺點是有時候打字快一點的話會不小心觸發就跳到終端機

macvim 我有安裝一個 plugin 叫 rails.vim ,這應該有用 vim 寫 rails 的人都知道...,它提供了在 command 模式下輸入幾個關鍵字就跳到某 model/view/controller 的功能,例如我要切到 views/posts/index.html.haml ,就輸入 :Rview posts/index ,它有提示功能,所以通常不需要把整串手動打完

chrome 我沒有什麼可以分享的

我處於這個狀態下已經有好幾個月,一直沒再精進,我後來有想到其實應該為瀏覽器和文字編輯器也加入 system-wide hotkey 才對,這樣我在這三者之間切換就完全不用 cmd + tab 了(對,我如果要跳到瀏覽器或文字編輯器還是用這個...),我知道 QuickSilver 可以定義這個,還沒摸索出比較好的組合

另外關於瀏覽器,不知道有沒有什麼擴充套件可以做到如下效果:因為常常搜尋資料開了好幾個分頁,有時候想起哪個搜尋結果要切過去,可是忘了在哪個分頁,一個一個切換看很麻煩,可不可以對某分頁某些內容標記之類的,之後搜尋關鍵字就跳到那分頁?

謝謝 😄

請問要如何判斷 transaction 是否有完成?

假設有一個 controller action 裡面有用到 ActiveRecord::Base.transaction

請問大家,除了在 transaction 結束後去檢查是否資料符合預期,還有沒有什麼方法可以知道 transaction 有沒有執行完成(或是知道 transaction rollback 了)?

e.g.

class IssuesController
  def lock
    ActiveRecord::Base.transaction do
      issue = Issue.find(params[:id]).update!(locked: true)
      issue.lock_log = LockLog.create!(reason: params[:reason], locked_by: current_user.name)
    end

    # 如果有辦法知道 transaction 是否完成就可以像下面這樣
    if transaction_succeed
      render json: {updated: true}
    else
      render json: {updated: false}
    end
  end
end

請問git rebase的這個指令為何重要?

各位朋友好,

最近我有幸被一些前輩提攜共同開發一些專案,
其中他們提到git rebase這個指令相當重要,

但我不懂的是,我在Terminal下,使用 git merge也可以達到相同的效果
為何有的時候還是被修改改用git rebase呢?

查了一些網誌,有些人竟然耍酷只有說『因為就沒有commit。』
原因就是 沒有commit 點flow圖比較好看嗎?

謝謝大家...

想請教一下,用 Passenger + Apache2 來佈署 Ruby on Rails 時,到底哪些config要做修改?有沒有範例可以參考?

我的環境是 ubuntu 14.04.03LTS + RVM + Ruby 2.2.0 + Rails 4.2.0

我的設定如下:

(1). 執行 RAILS_ENV=production rake secret 把值存到兩處
一. /etc/bash.bashrc
export SECRET_KEY_BASE='ooxxooxxooxx.....'
export DATABASE_URL='mysql2://root:password@localhost/abc'
export ABC_DATABASE_PASSWORD='password'
export RAILS_SERVE_STATIC_FILES='true'
export RAILE_ENV='production'
二. config/initializers/devise.rb
config.secret_key = 'ooxxooxxooxx.....'

(2). 執行 RAILS_ENV=production rake assets:precompile

(3). 修改 Gemfile 加入
gem 'passenger'
group :production do
gem 'mysql2', '0.3.20'
end

(4). 執行 bundle
(5). 安裝 Passenger => passenger-install-apache2-module
(6). 把設定存到 /etc/apache2/mods-available/passenger.conf
和 passenger.load
(7). 執行 a2enmod passenger
(8). 新增 /etc/apache2/sites-available/abc.tw.conf
加入
<VirtualHost *:80>
ServerName abc.tw
DocumentRoot /www/abc/public
#PassengerRuby /usr/local/rvm/gems/ruby-2.2.0@rails420/wrappers/ruby #註:這行不確定要不要增加
<Directory /www/abc/public/>
AllowOverride all
Options -MultiViews
Require all granted

LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/abc-error.log
CustomLog ${APACHE_LOG_DIR}/abc-access.log combined

(9). 執行 a2ensite abc.tw
(10). 重啟服務 sudo service apache2 restart
(11). 執行 RAILS_ENV=production rake db:create db:migrate
(12). 瀏覽網址 http://abc.tw 噴錯!

錯誤訊息如下:
前台:Incomplete response received from application
Log:
[Sat Oct 10 17:33:34.138458 2015] [authz_core:debug] [pid 5262] mod_authz_core.c(802): [client 1.2.3.4:42828] AH01626: authorization result of Require all granted: granted
[Sat Oct 10 17:33:34.138508 2015] [authz_core:debug] [pid 5262] mod_authz_core.c(802): [client 1.2.3.4:42828] AH01626: authorization result of : granted
[Sat Oct 10 17:33:34.426129 2015] [authz_core:debug] [pid 5262] mod_authz_core.c(802): [client 1.2.3.4:42828] AH01626: authorization result of Require all granted: granted, referer: http://abc.tw/
[Sat Oct 10 17:33:34.426148 2015] [authz_core:debug] [pid 5262] mod_authz_core.c(802): [client 1.2.3.4:42828] AH01626: authorization result of : granted, referer: http://abc.tw/

麻煩大家了 :p

Simple Form使用helper但設定的input屬性無效

各位前輩好,如題,我想判斷若attribute有值才顯示值,沒值的時候則顯示輸入欄位
但我寫的這個helper除了基本的輸入欄之外,placeholder、hint等等的選項都無法生效

module UsersHelper
  def render_input_or_text( f, obj, attribute )
    return obj.public_send(attribute) if obj.public_send(attribute)
    f.input attribute.to_sym, placeholder: attribute
                            # 此處之後,任何選項都無法生效
  end
end

使用方式:
users/_user.html.haml

= simple_form_for user, wrapper: :horizontal_table_form do |f|
  = render_input_or_text(f, user, 'birthday')

若是用partial就沒問題(不過這樣用法不太好,所以想盡量避免)

/ users/_input_or_text.html.haml
- if obj.public_send(attribute)
  = obj.public_send(attribute)
- else
  = f.input attribute.to_sym, placeholder: attribute   <---OK,正常顯示
/ users/_user.html.haml
= simple_form_for user, wrapper: :horizontal_table_form do |f|
  = render 'input_or_text', f: f, obj: user, attribute: 'birthday'

另外這是我用的wrapper
simple_form_bootstrap.rb

config.wrappers :horizontal_table_form, tag: 'td', class: 'form-group', error_class: 'has-error' do |b|
    b.use :html5
    b.use :placeholder
    b.use :input, class: 'form-control'
end

我也試過換回預設的horizontal_form的wrapper過,依然還是沒有placeholder。
感謝各位的幫助!

請問有定期的 Ruby/Rails 社群活動嗎?

感謝大家回答,將問題直接變成公佈欄

台北

Rails Taiwan Meetup

  • 每週二 晚上07:30
  • 在 Deroot 休閒空間 (新生南路一段60號B1,捷運忠孝新生站五號出口)

Rails 新手村

  • 每週四 晚上07:30
  • 在 Deroot 休閒空間 (新生南路一段60號B1,捷運忠孝新生站五號出口)
  • Slack

Ruby Tuesday

  • 偶爾會舉辦

Taipei.rb

  • 只辦過一次

桃園

桃園Ruby on Rails讀書會

  • 每月第一、三週六上午10-12點 (遇連假若更動會提前告知)
  • 地點在桃園市中壢區環北路398號5F-7 (中壢區公所旁,慈惠三街口)

高雄

高雄 Rails Meetup

  • 每週三 (7:00 PM - 10:30 PM)
  • 於左營 Kakaja 咖啡廳舉辦
  • Slack,Meetup

如何使用JavaScript即時驗證(real-time validate)表單欄位?

不好意思,這也許是很基本的前端問題,但可能關鍵字下的不對,一直找不到我要的資訊

我用了 client_side_validations 這個 gem ,它提供前端欄位驗證和顯示 validation errors 訊息,我想要做到可以「很即時的」當使用者在輸入時就邊檢查這資料是否 valid ,在欄位邊框顯示紅色、綠色...等等,忘記在什麼網站有看過這樣的功能

client_side_validations 這個 gem 處理驗證部分的 JS 程式碼約兩三百行,可是看不太懂,想說如果可以查看事件觸發時是哪段程式碼被執行時,就可以從中改造出自己要的功能

謝謝

禮拜四meetup出席資訊

哪邊可以知道新手村meetup確定會出席的資訊呢?

還是每個禮拜四都是一個surprise!!!!!

engine 使用宿主的 model

大家好~我來請教 engine 相關的問題
我在 engine 使用宿主的 model 使用如下圖方法
請問我要怎麼讓 _form.html.erb 的 author_name 顯示
當前的值(user.name),就第四張圖來看,結果是顯示空的
3
2
1
4

handshake

Problem Description

There are 10 types of people in the world: Those who understand binary, and those who don't.

You and your fellow cohort of those in the "know" when it comes to binary decide to come up with a secret "handshake".

1 = wink
10 = double blink
100 = close your eyes
1000 = jump
10000 = Reverse the order of the operations in the secret handshake.

handshake = SecretHandshake.new 9
handshake.commands # => ["wink","jump"]

handshake = SecretHandshake.new "11001"
handshake.commands # => ["jump","wink"]

The program should consider strings specifying an invalid binary as the value 0.

以上是題目的敘述
請幫我 code review 參數是 String 時 我不會解

https://gist.github.com/HACKeverything/ff5e7eac7dcb4a59ddea

另外附有 test code
https://gist.github.com/HACKeverything/51cd15318ae718d2808b

請問如果寫一個可以上傳多張照片的部落格,建議用哪種架構?

如題,假設我用rails g scaffold blog name content:text 產生部落格,照片搭配 Carrierwave套件,究竟該跟Rails101s的留言一樣,把照片獨立出來,然後用巢狀(nest)路由呢?還是乾脆簡單把照片用p1、p2、p3...的方式加入 blog 這個Model裡比較簡單方便? 因為我看到網路上是用另一種方式
accepts_nested_attributes_for :photos, allow_destroy: true

但是不太懂用法,可以解釋一下嗎?

https://u.osu.edu/hasnan.1/2014/03/30/rails-4-multiple-file-upload-with-carrierwave-nested-form-and-jquery-file-upload/

找 Ruby on Rails 工作

大家好,我叫Fred..

現在開始要找rails相關的工作!

可是發現inside job , ruby job, 66k job...等公司都不多,請教各位大大可否提供一些公司名稱阿!!!

這樣好歹可以投履歷阿阿阿阿.... T_T

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.