seen from China
seen from Argentina
seen from United Kingdom
seen from Canada
seen from Canada
seen from United States
seen from Italy
seen from United States
seen from Kazakhstan

seen from United Kingdom

seen from United States

seen from United States
seen from Russia
seen from China
seen from United States
seen from Venezuela

seen from Poland
seen from Somalia
seen from Norway

seen from Australia
New Post has been published on Ruby on Rails Tuts
New Post has been published on http://www.rortuts.com/ruby-on-rails/rails5-actioncontrollerparameters/
Rails 5: ActionController::Parameters
Rails 5: ActionController::Parameters Now Returns an Object Instead of a Hash.
Lot’s of people got confused. What was that?
So here is a small presentation which will quickly dive into it.
rails 4
raw_parameters = :name => 'rockers',:teams => :team1 => "37" parameters = ActionController::Parameters.new(raw_parameters) parameters # => "name"=>"rockers", "teams"=>"tet", "city"=>"Los Angeles" parameters.to_h # => "teams"=>"team1"=>"37" parameters.slice(:name,:city).to_h # => "name"=>"rockers", "city"=>"Los Angeles" parameters.to_unsafe_h.slice(:name, :city)
Rails 5
raw_parameters = :name => 'rockers',:teams => :team1 => "37",:city => 'delhi' parameters = ActionController::Parameters.new(raw_parameters) parameters # => <ActionController::Parameters "name"=>"rockers", "teams"=>"team1"=>"37" permitted: false> parameters.to_h # => parameters.slice(:name,:city).to_h # => Calling #to_h on this would return an empty hash because name and city aren’t permitted. parameters.to_unsafe_h.slice(:name, :city) # => "name"=>"et", "city"=>"Los Angeles"
Note1: By default controller and action parameters are allowed. To explicitly always allow other parameters you can set a configuration option in your application.rb config.always_permitted_parameters = %w( controller action param_1 param_2 )
Note2: this doesn’t affect accessing the keys in the params hash like params[:city]. You can view the Pull Request that implemented this change.
Some Code Snippets for Rails5.:
Json API
def create photos = [] photo_params.each do |p| photo = Photo.new(p) photos << photo if photo.save end render json: photos, status: 201 end def photo_params params.require(:photos).map do |p| ActionController::Parameters.new(p.to_hash).permit(:title, :src) end
Mandrill inbound webhooks
params = ActionController::Parameters.new( mandrill_events: [ msg: name: 'Francesco', age: 22, role: 'admin' , msg: name: 'steve', age: 22, role: 'admin' ] ) permitted = params.require(:mandrill_events).map # => ["name"=>"Francesco", "age"=>22, "name"=>"steve", "age"=>22]
Params hash in RSpec in Rails 5?
expect_any_instance_of(Hospital).to receive(:update).with(ActionController::Parameters.new('name':'MyString'))
Hey Guys! Hope you enjoyed this session :).If you like it then please share and let us know your views as well, we will try to answer your quetions.
For any proffesional assistance you can checkout our Ruby on Rails Application Development services or contact us.
Rails 5 + Webpack + React Boilerplate
Created a new boilerplate off an internal project we're setting up. It utilizes Rails 5 as the back-end core, Webpack for JavaScript and CSS asset compilation, and React as the chosen front-end framework. RSpec and Jest are both integrated as testing suites as well. Check it out at:
https://github.com/digital-telepathy/rails5-webpack-react-boilerplate
setup Rails 5 on Bash on Ubuntu on Windows
BashOnUbuntuOnWindowsでRails5をセットアップする
Install Bash
まずはWindows10(OS build 14393.10 以降)を用意する。
ControlPanelのプログラムメニュー内にある Windowsの機能の有効か無効か を選択する。その中にある Windows Subsystem for Linux にちぇっくを入れて再起動をかける。 これでBashのインストールができるはず。。
bash settings
bash を起動してテキトーにユーザ設定とかする。
apt-getのアップデートとか行う
$ apt-get update $ apt-get upgrade
gitをインストールする
$ apt-get install git
install ruby
rbenvをインストールする。
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv $ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build $ git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash # rbenvがインストールできたかどうかバージョン確認する $ rbenv -v rbenv 1.0.0-30-hoge
~/.bashrcに以下を追記します。
export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)"
Rubyのインストールに必要なもろもろのものをインストールする。
$ apt-get install gcc build-essential libssl-dev libreadline-dev zlib1g-dev
ようやくrubyをインストールする。今回はRuby2.3.1をインストールする。
$ rbenv install 2.3.1
かなり時間がかかるのでゲームでもしながら気長に待つ。
使用するRubyのバージョンを設定し、確認する
$ rbenv global 2.3.1 $ ruby -v
install Rails
gemをアップデートしておく
$ gem update --system
bundlerをインストールする。
$ gem install bundler
ここでNokogiri対策をしておく。
$ apt-get install libxml2 libxml2-dev libxslt-dev $ bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/include/libxml2"
いよいよrailsをインストールする!
$ gem install rails
ここもそこそこ時間がかかるので、気長に待つ。
とくになにも設定しなければsqliteを使うことになるのでsqliteをインストールする。Postgresは後日対応。。。
$ apt-get install sqlite3
ここでRailsプロジェクトを作ってみる
$ rails new test_project --skip-bundle $ cd test_project $ bundle install --path vender/bundle/
Railsサーバを立ち上げてみる。。。
$ bundle exec rails server
bundle がうまくいかない
$ bundle --- ERROR REPORT TEMPLATE ------------------------------------------------------- ... Error details ArgumentError: parent directory is world writable but not sticky ...... $
的なエラー。bundleのキャッシュファイルがなにかしら邪魔しているようなので、そのファイルの書き込み権限を変更する。
$ chmod -R +t ~/.bundle/cache
StackOverFlow
Rails server が動かない
$ bundle exec rails s /usr/local/lib/ruby/gems/2.3.1/gems/bundler-1.12.5/lib/bundler/runtime.rb:80:in 'rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)`
therubyracerを有効にすればいいらしい
# Gemfile gem 'therubyracer', platform: :ruby
Qiita
まだうごかない
$ bundle exec rails s => Booting Puma => Rails 5.0.0.rc1 application starting in development on http://localhost:3000 => Run 'rails server -h` for more startup options Exiting /home/josh/.rvm/gems/ruby-2.3.1@frontend/gems/rb-inotify-0.9.7/lib/rb-inotify/watcher.rb:74:in `initialize': Invalid argument - Failed to watch "/home/josh/.rvm/gems/ruby-2.3.1@frontend/gems/activesupport-5.0.0.rc1/lib/active_support/locale": the given event mask contains no legal events; or fd is not an inotify file descriptor. (Errno::EINVAL)
config/environments/development.rbの編集する。
# Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.file_watcher をコメントアウトする。
github
これでぼくは動きました!!
References
windowsのbashでRails環境を構築してみる。(Windows 10 Insider Preview 14316)
Example Gemfile files preparing for the next rails upgrade
Gemile.lock for rails 4 and 5 in the same app
Bölüm #20
[ Dinle ]
RailsConf 2016 Videoları
Timestamps değiştirmeden update
Facebook Messenger Gem
Stub, Mock, FactoryGirl?
Turkish Bin Numbers Gem
Logstasher Gem
ActionCable Tutorial
RailsApp Engine Tutorial
RailsConf2016 Notları
ApplicationRecord in Rails 5
Many times we do feel need to add a self desired functionality to ActiveRecord::Base and Monkey patching used to serve the purpose. Even though it worked just fine, there was no established structure to it. Often I’ve seen such monkey patches scattered all over the code-base adding to further confusion instead of providing any real value.
Rails 5 solves this by adding an abstract class ApplicationRecord to your app/models:
class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end
Now, you can add your modifications to this class:
class ApplicationRecord < ActiveRecord::Base include CommonWellTestedMethods self.abstract_class = true end
and since all your models will inherit from ApplicationRecord instead of ActiveRecord::Base you would get the desired effect and a commonly-practiced place to store your patches.
How to Build a Rails 5 API Only and Ember Application From Scratch
Rails API has been merged into Rails master branch. There is a how-to on building a Rails API app and integrating it with a simple Ember app. There also is a redux from one year before the merge, which explains how an Ember and Rails API app could be built before the Rails API merge. Read more: http://aviav.github.io/blog/2015/09/21/how_to_build_a_rails_5_api_only_and_ember_application_from_scratch/