Comments (40)
- link
- READMEを読む
- PR送るとしたら英語で送らないといけないから失敗したかも
from workshop.
- まずはこのissue読みだった
- 忘れてた
from workshop.
- READMEを読む
- PR送るとしたら英語で送らないといけないから失敗したかも
from workshop.
- README読み中
- リンクにアクセスしたがネットが重い...
from workshop.
- README -> gon.watch
- なにかヒントがあると思ったが最初はこのままREADMEを読んだほうがいいかも...
from workshop.
- README -> An example of typical use
- 文字で何するか書いてあるけどコードで書いてほしい
from workshop.
- README -> 1. Write variables by
:user_id => 1,
rubocop でいつも怒られるやつ
from workshop.
- README -> 1. Write variables by
gon.push(any_object)
any_objectどこやねん
from workshop.
- README
-
With the gon.watch feature you can easily renew data in gon variables!
知らんかった
from workshop.
- README
AMD compatible version
AMDってなんぞ CPU?
from workshop.
- README
- かと言ってソースがいきなりgemありきでインストール手順がなさそう
from workshop.
- README
- いきなりcontroller と viewに入っていったのでとりあえず動かすというまで読み解くのがちょっと面倒
from workshop.
- README
gem 'gon'
gem 'rabl-rails'
やっと出て来たのが rabl-rails 版w
from workshop.
- rabl-railsをやってみる
- せっかく出てきたからやってみるか...
mkdir -p ossws/gon
gem 'gon'
gem 'rabl-rails'
bundle
** エラー
Your Gemfile has no gem server sources. If you need gems that are not already on your
machine, add a line like this to your Gemfile:
source 'https://rubygems.org'
Could not find gem 'rabl-rails' in any of the gem sources listed in your Gemfile or
available on this machine.
from workshop.
- rabl-railsやってみる
- Gemfileを変更
source 'https://rubygems.org'
gem 'gon'
gem 'rabl-rails'
bundle
nokogiriさんきたで
Fetching gem metadata from https://rubygems.org/................
Fetching version metadata from https://rubygems.org/..
Resolving dependencies....
Installing rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Installing minitest 5.9.0
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Installing mini_portile2 2.1.0
Installing pkg-config 1.1.7
Using rack 1.6.4
Installing multi_json 1.12.1
Installing request_store 1.3.1
Using thor 0.19.1
Using bundler 1.11.2
Using tzinfo 1.2.2
Installing nokogiri 1.6.8 with native extensions
Using rack-test 0.6.3
Installing activesupport 4.2.6
Using loofah 2.0.3
Using rails-deprecated_sanitizer 1.0.3
Installing rails-html-sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Installing actionview 4.2.6
Installing actionpack 4.2.6
Using gon 6.0.1
Installing railties 4.2.6
Installing rabl-rails 0.4.3
Bundle complete! 2 Gemfile dependencies, 27 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
成功して良かった
nokogiriの不安感やばい
from workshop.
- rabl-rails 読む
- 俺は
gon
を使いたいんだ...
from workshop.
- rabl-rails
Rails 3+ templating system with JSON, XML and Plist support.
便利そうだけどRails3だ
from workshop.
- railsアプリケーション作る
- 俺は
gon
を使いたいだけなんだ - まあ
Your Rails variables in your JS
だししょうがない気もする
from workshop.
- rails アプリケーションを作る
mkdir test_app
cd test_app
vi Gemfile
Using pkg-config 1.1.7
source 'https://rubygems.org'
gem 'rails'
bundle
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.9.0
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using pkg-config 1.1.7
Using rack 1.6.4
Installing mime-types-data 3.2016.0521
Using arel 6.0.3
Using bundler 1.11.2
Installing concurrent-ruby 1.0.2
Using thor 0.19.1
Using tzinfo 1.2.2
Using nokogiri 1.6.8
Using rack-test 0.6.3
Installing mime-types 3.1
Installing sprockets 3.6.0
Using activesupport 4.2.6
Using loofah 2.0.3
Installing mail 2.6.4
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.3.6
Installing activemodel 4.2.6
Using rails-html-sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Installing activejob 4.2.6
Installing activerecord 4.2.6
Using actionview 4.2.6
Using actionpack 4.2.6
Installing actionmailer 4.2.6
Using railties 4.2.6
Installing sprockets-rails 3.0.4
Installing rails 4.2.6
Bundle complete! 1 Gemfile dependency, 36 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
bundle exec rails new .
exist
create README.rdoc
create Rakefile
create config.ru
create .gitignore
conflict Gemfile
Overwrite /Users/satoshi.nakajima/work/ossws/gon/test_app/Gemfile? (enter "h" for help) [Ynaqdh] Y
force Gemfile
create app
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/views/layouts/application.html.erb
create app/assets/images/.keep
create app/mailers/.keep
create app/models/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/bundle
create bin/rails
create bin/rake
create bin/setup
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/secrets.yml
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/assets.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/cookies_serializer.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/session_store.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/robots.txt
create test/fixtures
create test/fixtures/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/test_helper.rb
create tmp/cache
create tmp/cache/assets
create vendor/assets/javascripts
create vendor/assets/javascripts/.keep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.keep
run bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.9.0
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using pkg-config 1.1.7
Using rack 1.6.4
Using mime-types-data 3.2016.0521
Using arel 6.0.3
Using debug_inspector 0.0.2
Using bundler 1.11.2
Installing byebug 9.0.5 with native extensions
Installing coffee-script-source 1.10.0
Installing execjs 2.7.0
Using thor 0.19.1
Using concurrent-ruby 1.0.2
Using multi_json 1.12.1
Installing sass 3.4.22
Installing tilt 2.0.5
Installing spring 1.7.1
Installing sqlite3 1.3.11 with native extensions
Installing rdoc 4.2.2
Using tzinfo 1.2.2
Using nokogiri 1.6.8
Using rack-test 0.6.3
Using mime-types 3.1
Using binding_of_caller 0.7.2
Using coffee-script 2.4.1
Installing uglifier 3.0.0
Using sprockets 3.6.0
Using sdoc 0.4.1
Using activesupport 4.2.6
Using loofah 2.0.3
Using mail 2.6.4
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.3.6
Using activemodel 4.2.6
Installing jbuilder 2.5.0
Using rails-html-sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using activejob 4.2.6
Using activerecord 4.2.6
Using actionview 4.2.6
Using actionpack 4.2.6
Using actionmailer 4.2.6
Using railties 4.2.6
Using sprockets-rails 3.0.4
Installing coffee-rails 4.1.1
Installing jquery-rails 4.1.1
Using rails 4.2.6
Using sass-rails 5.0.4
Installing web-console 2.3.0
Installing turbolinks 2.5.3
Bundle complete! 12 Gemfile dependencies, 56 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
run bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted
膨大なファイルできたやつ
from workshop.
- gon rabl-rails いれる
- rails ありきだからGemfileに追記する形で書いてあるのか...
gem 'gon'
gem 'rabl-rails'
bundle
入った
これ Rabl-Rails みないとあかんやつや
from workshop.
- 普通の rails で gon を動かす
- rabl読むの辛いから普通のrailsで動かすために上に戻ってその通り書いてみる
- 最初から普通のrailsで動かすための一通りの手順を入れてほしい(rails入っている前提でなく...)
- この辺
from workshop.
- rails アプリケーションを作る
- 確認用のcontrollerとviewを作る
vi app/views/application.html.erb
下記LINEを追加
一度使ったことあるからなんとなく入れることもわかるけど一発でわかるのだろうか?
でも、このまままるっとコピっても動くからよし?
<%= Gon::Base.render_data %>
controllerを作る
bundle exec rails g controller test
Running via Spring preloader in process 41486
create app/controllers/test_controller.rb
invoke erb
create app/views/test
invoke test_unit
create test/controllers/test_controller_test.rb
invoke helper
create app/helpers/test_helper.rb
invoke test_unit
invoke assets
invoke coffee
create app/assets/javascripts/test.coffee
invoke scss
create app/assets/stylesheets/test.scss
@your_int = 123
@your_array = [1,2]
@your_hash = {'a' => 1, 'b' => 2}
gon.your_int = @your_int
gon.your_other_int = 345 + gon.your_int
gon.your_array = @your_array
gon.your_array << gon.your_int
gon.your_hash = @your_hash
gon.all_variables # > {:your_int => 123, :your_other_int => 468, :your_array => [1, 2, 123], :your_hash => {'a' => 1, 'b' => 2}}
gon.your_array # > [1, 2, 123]
gon.clear # gon.all_variables now is {}
from workshop.
- rails アプリケーション上でgonを動かす
- routes と view を作るの忘れてた
config/route.rb
...
get '/test' => 'test#index'
test/index.erb
test
from workshop.
- rails アプリケーション動いた
- そのままコピペすると
gon.clear
が入っているので何も出ないでちょっと困りそう
from workshop.
- rails アプリ動かしながら
- tutorial ぐらいあるとパっと動きが確認できるので助かる
from workshop.
- gon で rspec を動かしてみよう
bundle exec rspec
/Users/satoshi.nakajima/work/ossws/gon/gon/spec/gon/global_spec.rb:1:in `<top (required)>': uninitialized constant Gon::Global (NameError)
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `load'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `each'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:106:in `setup'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:92:in `run'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in `run'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rspec-core-3.4.4/exe/rspec:4:in `<top (required)>'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/bin/rspec:23:in `load'
from /Users/satoshi.nakajima/.rbenv/versions/2.2.3/bin/rspec:23:in `<main>'
なんだろうか
from workshop.
- rspec 動かす
- contributing 書いてほしい
from workshop.
- rspecを動かす
- gem の spec はこう動かすのか...
bundle exec rake spec
from workshop.
- issueの内容を考える(思案中)
*
初めに instration をつけてほしい
その中で rails と gon が使える簡単な example を入れてほしい
rails new から いれたいなーと思ったけど
Very good and detailed example and reasons to use is considered in railscast by Ryan Bates
があったっぽいできれば readme 上で完結したい
contributing を作って欲しい
from workshop.
- issueの内容を考える(思案中)
# or new syntax
gon.push({
:user_id => 1,
:user_role => "admin"
})
を
user_id: 1
とかに書き直す
from workshop.
- issueを考える
- そのまま書くと
gon.clear
が入ってて動きが不安
from workshop.
- issueの内容を考える
readme を読んでさっと確認したいので rails と gon を含んだものを example に載せてほしい
Usage のところで gon.clear が入っているがそのまま下の example と一緒に動かすと何も表示されずに困るのでコメントとかにしておいてほしい
from workshop.
- issue
- Usage のコードをそのまま貼り付けて動かすと何も値がでないので動くものをおいておいてほしい
gon.clear
が問題だと思うのでコメントアウトしてもらえるとさっと動くので助かる
from workshop.
- issueを考える
開発者向け
rails の環境を構築して gon をドキュメント通りに導入して Usage のところを一通りコピーして実行すると alert
で何かが表示されるのが期待されるが何も変数が表示されずに困った。
理由は controller のコードに gon.clear
が最後に書かれているので起こった問題だった。
なので、 gon.clear
は便利な機能だと思うがコメントアウトなどで書いておいてもらえると嬉しい。
from workshop.
- issue を考える
サンプルコードをコピーして実行したが動かなかった
rails の環境を構築して gon をドキュメント通りに導入して Usageのところを一通りコピーして実行すると alert
で何かが表示されるのが期待されるが何も変数が表示されずに困った。
下記に作成手順を示します。
mkdir test_app
cd test_app
vi Gemfile
Gemfile
source 'https://rubygems.org'
gem 'rails'
bundle
...
bundle exec rails new .
...
- Gemfileにgonを追加
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'gon' # add
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
bundle
...
vi app/views/application.html.erb
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>TestApp</title>
<%= Gon::Base.render_data %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
bundle exec rails g controller test
...
config/routes.rb
get '/test' => 'test#index'
test/index.erb
test
app/controllers/test_controller.rb
class TestController < ApplicationController
def index
@your_int = 123
@your_array = [1,2]
@your_hash = {'a' => 1, 'b' => 2}
gon.your_int = @your_int
gon.your_other_int = 345 + gon.your_int
gon.your_array = @your_array
gon.your_array << gon.your_int
gon.your_hash = @your_hash
gon.all_variables # > {:your_int => 123, :your_other_int => 468, :your_array => [1, 2, 123], :your_hash => {'a' => 1, 'b' => 2}}
gon.your_array # > [1, 2, 123]
gon.clear # gon.all_variables now is {}
end
end
app/assets/javascripts/test.coffee
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
alert(gon.your_int)
alert(gon.your_other_int)
alert(gon.your_array)
alert(gon.your_hash)
試しに controller
のコードで gon.clear
をコメントアウトしたら直った。
app/controllers/test_controller.rb
#gon.clear # gon.all_variables now is {}
なので、 gon.clear
は便利な機能だと思うがコメントアウトなどで書いておいてもらえると嬉しい。
from workshop.
- 英語にしてみる
sample code do not run as expected
i build rails app with gon.
i installed gon using your documentation.
and, i copied the code from Usage.
i expected to display something variables in alert box.
but, display nothing.
show my steps below:
mkdir test_app
cd test_app
vi Gemfile
Gemfile
source 'https://rubygems.org'
gem 'rails'
bundle
...
bundle exec rails new .
...
- add
gon
into Gemfile
Gemfile
gem 'gon' # add
bundle
...
vi app/views/application.html.erb
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>TestApp</title>
<%= Gon::Base.render_data %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
bundle exec rails g controller test
...
config/routes.rb
get '/test' => 'test#index'
test/index.erb
test
app/controllers/test_controller.rb
class TestController < ApplicationController
def index
@your_int = 123
@your_array = [1,2]
@your_hash = {'a' => 1, 'b' => 2}
gon.your_int = @your_int
gon.your_other_int = 345 + gon.your_int
gon.your_array = @your_array
gon.your_array << gon.your_int
gon.your_hash = @your_hash
gon.all_variables # > {:your_int => 123, :your_other_int => 468, :your_array => [1, 2, 123], :your_hash => {'a' => 1, 'b' => 2}}
gon.your_array # > [1, 2, 123]
gon.clear # gon.all_variables now is {}
end
end
app/assets/javascripts/test.coffee
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
alert(gon.your_int)
alert(gon.your_other_int)
alert(gon.your_array)
alert(gon.your_hash)
i tried to commentout gon.clear
line, this issue is solved!
app/controllers/test_controller.rb
#gon.clear # gon.all_variables now is {}
so, gon.clear
is useful features!
but, i want to commentout gon.clear
line in sample code.
from workshop.
rubyとrails のバージョンを書く
from workshop.
- issue を考える
サンプルコードをコピーして実行したが動かなかった
rails の環境を構築して gon をドキュメント通りに導入して Usageのところを一通りコピーして実行すると alert
で何かが表示されるのが期待されるが何も変数が表示されずに困った。
試しに controller
の gon.clear
をコメントアウトしたら表示されるようになったので、サンプルコード上では gon.clear
をコメントアウトにしてほしい。
version
には関係ないと思うが、記載します
rails: 4.2.6
ruby: 2.2.3
# gon.clear
下記に作成手順を示します。
mkdir test_app
cd test_app
vi Gemfile
Gemfile
source 'https://rubygems.org'
gem 'rails'
bundle
...
bundle exec rails new .
...
- Gemfileにgonを追加
Gemfile
gem 'gon' # add
bundle
...
vi app/views/application.html.erb
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>TestApp</title>
<%= Gon::Base.render_data %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
bundle exec rails g controller test
...
config/routes.rb
get '/test' => 'test#index'
test/index.erb
test
app/controllers/test_controller.rb
def index
@your_int = 123
@your_array = [1,2]
@your_hash = {'a' => 1, 'b' => 2}
gon.your_int = @your_int
gon.your_other_int = 345 + gon.your_int
gon.your_array = @your_array
gon.your_array << gon.your_int
gon.your_hash = @your_hash
gon.all_variables # > {:your_int => 123, :your_other_int => 468, :your_array => [1, 2, 123], :your_hash => {'a' => 1, 'b' => 2}}
gon.your_array # > [1, 2, 123]
#gon.clear # gon.all_variables now is {}
end
app/assets/javascripts/test.coffee
alert(gon.your_int)
alert(gon.your_other_int)
alert(gon.your_array)
alert(gon.your_hash)
from workshop.
- issue を考える
sample code do not run as expected
Hi.
I build rails app with gon.
I installed gon using your documentation.
and, I copied the code from Usage.
I expected to display something variables in alert box.
but, display nothing.
I tried to commentout gon.clear
line, this issue is solved!
so, gon.clear
is useful features!
but, I want to commentout gon.clear
line in sample code like this.
@your_int = 123
@your_array = [1,2]
@your_hash = {'a' => 1, 'b' => 2}
gon.your_int = @your_int
gon.your_other_int = 345 + gon.your_int
gon.your_array = @your_array
gon.your_array << gon.your_int
gon.your_hash = @your_hash
gon.all_variables # > {:your_int => 123, :your_other_int => 468, :your_array => [1, 2, 123], :your_hash => {'a' => 1, 'b' => 2}}
gon.your_array # > [1, 2, 123]
#gon.clear # gon.all_variables now is {}
show ruby and rails versions.
rails: 4.2.6
ruby: 2.2.3
appendix) show my steps.
mkdir test_app
cd test_app
vi Gemfile
Gemfile
source 'https://rubygems.org'
gem 'rails'
bundle
...
bundle exec rails new .
...
Gemfile
gem 'gon' # add
bundle
...
application.html.erb
...
<%= Gon::Base.render_data %>
...
bundle exec rails g controller test
...
config/routes.rb
get '/test' => 'test#index'
test/index.erb
test
app/controllers/test_controller.rb
def index
@your_int = 123
@your_array = [1,2]
@your_hash = {'a' => 1, 'b' => 2}
gon.your_int = @your_int
gon.your_other_int = 345 + gon.your_int
gon.your_array = @your_array
gon.your_array << gon.your_int
gon.your_hash = @your_hash
gon.all_variables # > {:your_int => 123, :your_other_int => 468, :your_array => [1, 2, 123], :your_hash => {'a' => 1, 'b' => 2}}
gon.your_array # > [1, 2, 123]
gon.clear # gon.all_variables now is {}
end
app/assets/javascripts/test.coffee
alert(gon.your_int)
alert(gon.your_other_int)
alert(gon.your_array)
alert(gon.your_hash)
from workshop.
お疲れさまでした!
from workshop.
Related Issues (20)
- OSS Gate Workshop: online: 2024-06-08: fusen: OSS_NAME: Work log HOT 21
- OSS Gate Workshop: online: 2024-06-08: kuraryu: wheel: Work log HOT 41
- OSS Gate Workshop: online: 2024-06-08: wxqmailbox: Tabnine: Work log HOT 5
- OSS Gateオンラインワークショップ2024-07-27
- OSS Gateワークショップ2024-09-xx HOT 1
- OSS Gate Workshop: online: 2024-07-27: daipom: Fluentd: Work log HOT 11
- OSS Gate Workshop: online: 2024-07-27: blacktoad30: GNU Guix: Work log HOT 10
- OSS Gate Workshop: Online: 2024-07-27: jkyochen: Fluentd: Work log HOT 19
- OSS Gate Workshop: online: 2024-07-27: otegami: PGroonga: Work log HOT 5
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: tadsan: deepcopy: Work log HOT 5
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: hana979: laravel/pint: Work log HOT 11
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: myou1985: django-debug-toolbar: Work log HOT 15
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: noko1024: python/websockets Work log HOT 4
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: fujiokayu: ${OSS_NAME}: Work log HOT 1
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: tetrapod418: ${OSS_NAME}: Work log HOT 29
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: otoyuzu705: python-dotenv: Work log HOT 14
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: satou-haruka-37: ransack: Work log HOT 47
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: 斉藤賢悟: react-hook-form: Work log HOT 15
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: pepi-p: python-skyfield: Work log HOT 7
- OSS Gate Workshop: ゆるい勉強会旭川: 2024-07-28: TadaTeruki: winit: Work log HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workshop.