14. ちなみに
Railsではtypeというカラム名は予約語となっているらしく、
使うことが出来ません。
おこられます。
しかもViewを表示するときになってはじめて気づかされま
す。
The single-table inheritance mechanism failed to locate the subclass: '
インスタント'. This error is raised because the column 'type' is
reserved for storing the class in case of inheritance. Please rename
this column if you didn't intend it to be used for storing the
inheritance class or overwrite MstCard.inheritance_column to use
another column for that information.
カラム名として使えない名前は他にもあるので、気をつけてください!
16. 設定を省略してかける
resources :mst_cards do
collection do
get 'search'
end
end
earch_mst_cards GET
mst_cards
GET
POST
new_mst_card
GET
edit_mst_card
GET
mst_card
GET
PATCH
PUT
DELETE
/mst_cards/search(.:format)
/mst_cards(.:format)
/mst_cards(.:format)
/mst_cards/new(.:format)
/mst_cards/:id/edit(.:format)
/mst_cards/:id(.:format)
/mst_cards/:id(.:format)
/mst_cards/:id(.:format)
/mst_cards/:id(.:format)
21. user_controller.rb
def add_card
#カードの所持数を増やす処理
respond_to do |format|
format.js #renderを実行しない
end
end
user/add_card.js.erb
var dom = $(".card_count", "#card_<%= @user_card.card_id %>")
var val = dom.text()
val = Number(val) || 0
val = val+1
dom.text(val)
30. 以下のコマンドを実行してHerokuにアプリを登録します。
git push heroku master
ちなみに、Herokuではsqlite3とmysqlをサポートしていないた
め、herokuにアップするときにはposgresqlを使うようにしま
す。
Gemfile
group :production do
gem "pg"
end
group :development, :test do
gem "sqlite3"
end
またHerokuでpostgresqlを使用す場合はHerokuの
postgresqlプラグインをインストールする必要があります。
インストールはherokuのページから可能です。