2015-04-01から1ヶ月間の記事一覧

Rails undefined method `delete'

'delete'と書いていないのにエラー: undefined method `delete' for true:TrueClass もとのコード: =form_for :school, url: schools_path do |f| =check_box :kindergarten, { :multiple => true }, true, false 直したコード: =form_for :school, url: …

Pusher を使ってRailsチャットを実装するためのリンク集

・Add Realtime chat widget to any web page | Pusher ・RailsとHerokuでノーティフィケーションをプッシュする / PusherとTurbolinksの兼ね合い www.workabroad.jp ・Documentation | Pusher ・ Ruby - Rails3.2.8 + Pusher - Qiitaqiita.com ・PusherとRu…

Rails4で多対多のリレーションをモデルに実装する - Rails Webookruby-rails.hatenadiary.com

TimeTicket, SPIKE 比較

IB・留学・帰国子女枠受験で差をつける!Skypeセッションspike.cc Pay Now

heroku ステージング環境づくり/ Permission Denied, error 503

エラー内容: [Terminal] git push heroku bugfix:master ! Heroku has temporarily disabled this feature, please try again shortly. ! See http://status.heroku.com for current Heroku platform status. fatal: Could not read from remote repository…

heroku domainをほかのherokudomainに変える方法

はじめ: ➜ ibhiroba1 git:(bugfix) git remote -vheroku git@heroku.com:ibhiroba1-0403.git (fetch)heroku git@heroku.com:ibhiroba1-0403.git (push)origin git@github.com:HOkn/ibhiroba1.git (fetch)origin git@github.com:HOkn/ibhiroba1.git (push) …

Rails Appをherokuにデプロイする

RailsアプリをHerokuにデプロイするcyllabus.jp bundle install heroku run rake db:migrateを忘れないこと! How to change git url for app on Herokustackoverflow.com

Rails sorcery 新規登録ができない

解決:view file form_for を<table> タグ内部でなく 外部にして、tableタグを囲む。 コントローラー: class RegistrationsController < ApplicationController def new @user = User.new end def create @user = User.new(params_user) if @user.save raise login</table>…

Railsログアウトできない sorcery

terminal でのログ: Started DELETE "/sessions" for ::1 at 2015-04-08 23:57:38 +0900Processing by SessionsController#destroy as HTMLCan't verify CSRF token authenticityRedirected to http://localhost:3000/questionsCompleted 302 Found in 5ms …

routes.rb でエラー /1 ではなく.1となってしまう

問題: users#show にいきたいのだがhttp://localhost:3000/users/1 とはならず http://localhost:3000/users.1 となってしまった。 エラー: ActiveRecord::RecordNotFound at /users.1 Couldn't find User with 'id'= 他のページでのエラー: NoMethodErro…

routingエラー

users_path GET /users(.:format) users#show GET /users/:id(.:format) users#show

Rails HAMLでもGoogle Analyticsを使える!gem google-analytics-rails

https://github.com/bgarret/google-analytics-rails

Rails radio button エラー解決した例

ラジオボタン(radio button)でのエラー なぜかvalueを選ぶとエラーメッセージが出ずに、コントローラーを呼べない。 解決: value = "ibparent" ではなく、 :value => "parent"などとすること! ただしいコード: %tr %td.alignright 立場*: %td.radio =f…

Rails trタグの大きさを変える方法

table, tbody, td, tr, の大きさを変える方法 padding-bottom: 20px など やっても意味ない: marginの定義 How do I increase the width of a column in an HTML table?stackoverflow.com

table テーブルのデータのidだけ取る

@categoriesid = Category.select(:id)

Rails projectを作るときの順番 メモ

1projectをつくる 2modelをつくる 3model files (---.rb)を書く 4rails console コンソールでデータを入力して、controllerに書く処理を確認 5view file ビューを書く 6(gem 'better errors'やinspectメソッドを使って)ビューからコントローラーに渡…

Rails nested_attributes Could not find the association :question_category in model Question

間違えたコード: / <% @categories.each do |c| %> / <%= check_box :category, :id, {}, c.id %> / <%= c.name %> / <% end %> / - @categoriesid.each do |id| / = check_box :id, id / category, nil / = category.name / - @categories.each do |catego…

Rails 複数選択check_box_tag 例

"undefined method 'merge'などのエラーについて 解決例: = f.check_box(:kindergarten, {}, true, false)注意! = f.check_box ( :high, { :multiple => true }, true, false)のようにboxのあとスペースを入れるとエラー! syntax error, unexpected ',', …

Rails each_with_index tag 使い方

例: View file: - @categories.each_with_index do |category,i| = check_box_tag "category#{i+1}", category.id = category.name 注意:このとき|i, category|とするとエラー。| ビュー: カテゴリーidを入れるパラメーターの名前を category1 category2 …

Rails 使い分け find_by! where

お気に入り機能 お気に入りに入っているかどうかを見極める関数 questionをお気に入りに追加する場合、model/question.rb に関数を書く。 エラーしたコード; def favorited_by?(user, question) Favorite.where(user_id: user.id).find_by!(question_id: qu…