Rails
GET with Custom Header by Alamofire let URL = NSURL(string: "https://dinner.please")! let mutableURLRequest = NSMutableURLRequest(URL: URL) let message = "I want to eat!" mutableURLRequest.HTTPMethod = "GET" mutableURLRequest.setValue(mess…
忘れていたので、復習の意味でメモ。 AlamofireでCustom HeadersでGET let URL = NSURL(string: "https://onedari.please")! let mutableURLRequest = NSMutableURLRequest(URL: URL) let message = "tabetai" mutableURLRequest.HTTPMethod = "GET" mutable…
What I want to do GET http://domain.jp/api/2.1.1/users or GET http://domain.jp/meats/score/21293.02 (You may say URL with parameter including dot is not good....) How I failed config/routes.rb get 'meats/score/:score' => 'meats#score' rout…
やりたいこと GET http://domain.jp/api/2.1.1/users とか GET http://domain.jp/meats/score/21293.02 とか、少数点、というかドットが入った形のURLを使う方法についてです。 (そもそもドットの入った値はURLに入れないほうが良いのかもしれませんが...)…
Japanese here uchinoinu.hatenablog.jp Situation Rails 4.2 Ruby 2.3 Spring 1.3.5 direnv 2.8.1 Manage environment variables by direnv run rails command using Spring Problem Adding new environment variables, rails c cannot load any environmen…
English here uchinoinu.hatenablog.jp 状況 Rails 4.2 Ruby 2.3 Spring 1.3.5 direnv 2.8.1 direnvで環境変数を管理している Springを使ってrailsコマンドを動かしている 問題 環境変数を追加したら、rails sは通るけど、rails cでは環境変数を読み込めなく…
Japanese here. uchinoinu.hatenablog.jp sass: img width: 100% Write like above, <style type="text/css"> img { width: 100%; } </style> Output html like above. Reference マークアッパー的 Slim 入門21の手引き | e2esound.com業務日誌
English here uchinoinu.hatenablog.jp 簡単でした sass: img width: 100% と書くと <style type="text/css"> img { width: 100%; } </style> と出力されます。 Reference マークアッパー的 Slim 入門21の手引き | e2esound.com業務日誌
日本語はこちら uchinoinu.hatenablog.jp What I want to do local --(git push origin master)--> bitbucket --> wercker --(passしたら)--> heroku Problems wercker is difficult to use for me Recently, wercker is really changeable. Free plan is wo…
English Version is here uchinoinu.hatenablog.jp やりたいこと Bitbucketにpushしたら、werckerが動いて、パスしたら、Herokuにデプロイされる local --(git push origin master)--> bitbucket --> wercker --(passしたら)--> heroku 問題 Werckerが変わり…
Memo require "rails_helper" RSpec.describe Api::V2::HogeController, type: :routing do describe "routing" do it "routes to #mine" do expect(:get => "/api/v2/hoges/mine").to route_to("api/v2/bookmarks#mine", format: "json") end . . .
Edit config/routes.rb, set only ominauth_callbacks outside of scope of locale. Rails.application.routes.draw do devise_for :users, skip: [ :session, :password, :registration, :confirmation ], controllers: { omniauth_callbacks: 'users/omnia…
paramsがこんな感じのとき { "foo": [ { "bar": "tar", "baz": "sar" }, { "bar": "tor", "baz": "sor" }, { "bar": "ter", "baz": "ser" }, { "bar": "tir", "baz": "sir" }, ] } StrongParametersで配列の中身を見る private def foo_params params.requir…
memo namespace namespace :api do get '/test' => 'tests#index' end => GET /api/test(.:format) api/tests#index scope scope :api do get '/test' => 'tests#index' end => GET /api/test(.:format) tests#index
症状 RailsでJSON API用のバックエンド(管理画面はactive adminを利用し、そこだけはhtmlを利用)を作っています。 認証周りにDeviseを利用しました。 Routingは↓な感じで。 # config/routes.rb namespace :api, format: 'json' do namespace :v1 do devise…
症状 何事も無ければ、active_adminを使っている場合、/adminにアクセスしたら、以下の様な画面が見れるはずです。 しかし、今回こんな感じになりました。 Started GET "/admin" for ::1 at 2015-05-12 18:06:23 +0900 Processing by Admin::DashboardContro…
こちらの記事の続きです。 Crafting Rails 4 Applications - capter 1-4 - Talking It to the Next Level - Satomi's Daily Notestsumekoara.hateblo.jp 1.5 まとめ この章ではPDFフォーマット用のrendererを作りました。このアイデアを使えば、csvやatomと…
こちらの記事の続きです。 Crafting Rails 4 Applications - capter 1-3 - Understanding the Rails Rendering Stack - Satomi's Daily Notestsumekoara.hateblo.jp 1.4 次のレベルへ rendererの実装に話を戻します。以下の様なcontrollerでないが起きるか勉…
こちらの続きです。 Crafting Rails 4 Applications - capter 1-2 - Writing the Renderer - Satomi's Daily Notestsumekoara.hateblo.jp 1-3. Rails Rendering Stackを理解する Action MailerとAction Controller はいくつかの共通機能を持っています。例え…
↓のつづきです。 Crafting Rails 4 Applications - capter 1-1 - Satomi's Daily Notestsumekoara.hateblo.jp 1.2 Rendererを書く まずはじめに、render()メソッドと許容されるいくつかのオプションについて話をしましょう。rendererとは何かということを正…
(source: http://whyzat.com/wp-content/uploads/2014/04/Useful-Dog.jpg) Version Ruby # 2.2.1 Rails # 4.2.0 Install $ vi Gemfile -------- # add gem 'annotate' -------- $ bundle install Make Config File(Task File) $ bundle exec rails g annotat…
In many cases, phantom.js is used to get screen capture. But wkhtmltoimage can be alternative. Install http://wkhtmltopdf.org/downloads.html $ sudo yum install -y openssl libX11 libXext libXext.so.6 $ cd /usr/local/src $ wget http://downlo…
to use bulk insert on Rails, add gem below. gem 'activerecord-import' In MySQL, bulk update can be used by this gem, but postgres..... sqlite..... update_all solution! # make all records with open: false to open: true Shop.where(open: fals…
Deviseを使ってユーザー登録を使用としたら、Devise::RegistrationsControllerの方のrespond_withのあたりでActionController::UnknownFormatエラーが吐かれました。 ルーティングはこんな感じ devise_for :users, :controllers => { :sessions => "users/se…
simple_formを使っています。 同じformを使ってcreateとupdateをすることが多いと思います。 症状 updateを叩いたつもりが、こんなエラーに出くわしました。 Routing Error No route matches [PATCH] “/hoge" ちなみにroutingは POST /hoge(.:format) hoge#c…
Install elasticsearch to Yosemite! Yosemite $ brew install elasticsearch # Elasticsearch Client gem 'elasticsearch-model' gem 'elasticsearch-rails' gem 'bonsai-elasticsearch-rails' $ bundle install Plugin Japanese Character Adaptor The Jap…
Rails4で作っているプロジェクトで、Carrierwaveを使おうとすると、RMagickも一緒に使うことが多いかと思います。 それらのセットアップ時のトラブルです。 エラーたち bundle installが落ちる $ bundle install --path vendor/bundle ---- An error occurre…
Rails4.2で作っていたプロジェクトをHerokuで運用していくことになりました。 しかし、さくらvpsやAWSを想定していたこともあり、慣れたMySQLをこれまで使っていました。 そこでMySQLからPostgresへ移し替えることになりまして、その際起きたトラブルのメモ…
こちらを参考ししました。 Ruby - RailsのApplication templateを使って開発の初速をあげよう! - Qiitaqiita.com まだコピペしては継ぎ接ぎしたり、試行錯誤中なので、 これから改善していきます。 http://techracho.bpsinc.jp/baba/2012_06_27/5811 tsumek…
Rails4.1系のプロジェクト名を変更する際のメモです。 手動 以下の二箇所で大丈夫そうです。。。。 config/application.rb config/initializers/session_store.rb module ProjectName end Rails.application.config.session_store :cookie_store, key: '_pro…