rake db:reset 㨠rake db:migrate:reset ã¯ã©ã¡ããä¸æ¦å ¨ã¦ã® DB ã dropï¼åé¤ï¼ããå¾ã« DB ä½æãç´ãã³ãã³ãã§ãããæ確ãªéããããã¾ããRuby on Rails ãã¥ã¼ããªã¢ã«ï¼å®ä¾ã使ã£ã¦ Rails ãå¦ã¼ãã§ã¯ãrake db:reset ããåºã¦ããªãã®ã§ãããrake db:migrate:reset ãç¥ã£ã¦ããã¨ç¶æ³æ¬¡ç¬¬ã§ã¨ã¦ã便å©ã§ããã¨ããããç§ã¯ããããã¡ããå¤ç¨ãã¦ãã¾ãã
Heroku Account Creation Next, create a Heroku account so you can deploy Rails. If you have an existing Heroku account and have already installed the Heroku Toolbelt for Mac then you can skip directly to the next section. Go to heroku.com and click Sign up for free Enter your email address and click Sign Up Check your inbox for an email from Heroku and click on the verification link in-order to ver
ã¹ããã¢ããªããä¼å¡ã®æ°è¦ç»é²ããã°ã¤ã³ã両æ¹ã§ããããã«APIãä½æä¸ãããããèªåã§ã¢ã¯ã»ã¹ãã¼ã¯ã³ãä½ã£ã¦OAuthèªè¨¼ãåºæ¥ãã®ã§ã¾ã¨ãã¦ããã ã¾ãä½ãããããï¼ ã¹ããã¢ããªã§APIèªè¨¼ãã§ããããã«ãOAuthãèªåã§ä½æãããã -> ã¹ããã¢ããªå´ã§ã¯ã¦ã¼ã¶åã¨ãã¹ã¯ã¼ããå ¥åããã°ãã¼ã¯ã³ãåã£ã¦æ¥ãã¦ããã®ãã¼ã¯ã³ã§åAPIã«ã¢ã¯ã»ã¹ããã°ã¦ã¼ã¶åºæã®æ å ±ãåã£ã¦æ¥ããããã«ãªãä»çµã¿ãä½ãã ã¹ããã¢ããªå´ã§ã¦ã¼ã¶ä½æãåºæ¥ãããã«ãããã -> APIã§ã¦ã¼ã¶ãä½ããããã«ããããã¡ããhttpsåæã ç°å¢ gemfile ruby '2.0.0' gem 'rails', '4.0.0' gem 'rails-api' gem 'active_model_serializers' gem 'mongoid', '4.0.0.alpha1' gem "moped
ã¯ããã« Ruby on Rails(以ä¸Rails)ã§MongoDBã使ãéã®ORãããã¼ã¨ãã¦ç¾å¨ã¯Mongoidãæ¨æºçã«ä½¿ç¨ãããããã«ãªãã¾ãããMongoidã¯Active Recordã«ä¼¼ãAPIãåãããã¤MongoDBã®ã¹ãã¼ãã¬ã¹ãããã¥ã¡ã³ãæåããã¤ãããã¯ã¯ã¨ãªãã¢ãããã¯æä½ã¨ãã£ãç¹å¾´ãRubyãã容æã«æ±ããããã«è¨è¨ããã¦ãã¾ãã æ¬è¨äºã§ã¯Mongoid 4.0.0ãRails 4.1.8ããã¼ã¹ã«ãRailsã§Mongoidã使ãå©ç¹ãè¿°ã¹ãå®éã«ãµã³ãã«ã¢ããªã±ã¼ã·ã§ã³ãåããã¦ç´¹ä»ãããã¨æãã¾ãã Mongoidã使ãå©ç¹ ããã¾ã§ã®ããã¸ã§ã¯ãã§ã¯Active Recordãä»ãã¦ä¸»ã«MySQLã使ç¨ãã¦ãã¾ããããMongoidã使ç¨ããããã«ãªã£ã¦ã以ä¸ã®å©ç¹ãå®æãã¦ãã¾ãã Active Recordã¨å ±éãããã¯æ¡å¼µããã¯ã¨ãªã¨æ°¸ç¶å
has_manyï¼throughã¨ãã§ã¢ãã«ããã¼ãã«ã®æ§æãèããã¨ãï¼ã©ããã¦ãã«ã©ã åã¨é¢é£ã¥ãããã¼ãã«ã®ååãä¸è´ããªãã£ããï¼æã¿éãã®å½åã§è¡ããªãå ´åãããï¼ ãã¡ããï¼ä¸ã¤ã®ãã¼ãã«ãï¼ä»ã®ãã¼ãã«ã®ã¬ã³ã¼ããè¤æ°æã¤ã ããªãï¼å½åã¯ã¹ãã¼ãã«æ±ºããããã®ã ããã©ï¼ ä»åã®ä¾é¡ã¯ï¼Userã¢ãã«ã«å¯¾ãããã©ãã¼ã»ãã©ãã¯ã¼ãå®ç¾ãããã¨ï¼ Userã¯ä¸ã¤ã®ãã¼ãã«ã§ãªããã°ãªããªããã¨ã¯ãããã¾ãããï¼ ã¨ãããã¨ã¯ï¼Userãã¼ãã«ãUserFollowã¨ããä¸éãã¼ãã«ãä»ãã¦ï¼Userãã¼ãã«ã®ã¬ã³ã¼ããhas_manyããã¨ããå½¢ãã¨ãï¼ ããã¬ãªã¬ãªã¨æ¸ãã¦ããã¾ãï¼ ã¾ãï¼ããããï¼å ããååã®çµ±ä¸ãé£ããããªå ´åã¯ãã¼ãã«ãå ã«ä½ã£ã¦ãã¾ãï¼ Userãã¼ãã« id name 1 poteto 2 hoge UserFollowãã¼ãã« id user_id
ããã¾ã§ãä½åº¦ãRailsãåå¼·ãããã¨ãã¦æ«æãã¦ããã Rails 㧠"ã¨ããããåãã³ã¼ã" ãæ¸ããããã«ãªã£ã人ã次ã«ééããåé¡ã¨ããã解決ãã¦ãããæ¬ã¾ã¨ã - 彼女ããã¯ãããã¡ããã¨å¼ã°ãã¦ãã¾ã ãèªãã§åå¼·ãããã¯ãªã£ãã®ã ããã©ãããããåã¯ã¾ã âã¨ããããåãã³ã¼ããæ¸ããããã«ãªã£ãâ æ°ããã¦ããªãã ããã§ãèªåã¯ããã°ã©ã ã¯å¾æãªæ¹ã ã¨æã£ã¦ããã大å¦ã¯æ å ±ç³»ã ã£ãããåãææ¥ãåãã人ãã¡ã®ä¸ã§ã¯ä¸æãããã°ã©ã ã§ããæ¹ã ã£ãã¨æããããã°ã©ã ãæ¸ããã¨èªä½ã¯å¥½ãã ããCãJavaãLispãã¢ã»ã³ãã©ã¾ã§ä¸»è¦ãªè¨èªã¯å¤§ä½ææ¡ãã¦ããã¤ããã ã ããã§ãRailsã¯é£ããã ãªãé£ããã®ãï¼ åæãã¦ã¿ã㨠ã¨ã«ããç¥ãã¹ããã¨ãå¤ã ãããé²æ©ãæ©ãããã£ããæ¶ãã¦ãããã«å¤åãã ãããã ãããã°å¤§ä¸å¤«ãã¨ããèå ¸ãç¡ã ããã ã¨æããCãLis
ã·ã©ãã¹ã¯ã ããããã¦å¦ã¹ãã ãã³ã³ã»ããã«ããã ããã°ã©ãã³ã°å¦ç¿ãµã¤ã ã§ããHTML/CSSãWordPressãRuby on RailsãBackbone.jsãªã©ã® WEBãã¶ã¤ã³ ã WEBã¢ã㪠ã®éçºãå¦ã¶ãã¨ãã§ãã¾ããç¹å¾´ã¨ãã¦ã GitHubãããã¥ã¬ã¼ã·ã§ã³ãã¦ããããã°ã©ã ãå©ç¨ãã¦å¦ç¿ã³ã¼ã¹ãä½æããã¦ãã¾ãã
Photo by Gonzalo Baeza | Flickr - Photo Sharing! Railsã§JSONãè¿ãAPIãä½æããã¾ããAPIã®ãã¹ãæ¹æ³ã説æãã¾ãã JSONãè¿ãAPIã¯ãRailsã®ActiveSupportããæ¡å¼µãããto_jsonã¡ã½ããã¨DMMãéçºããjbuilderã¨ããGemã使ãã¾ãã APIã®ãã¹ãã«ã¯ããªãã¿ã®RSpec3ã使ãã¾ãã åä½ç¢ºèª Rails 4.1.7 jbuilder 2.2.6 rspec-rails 3.1.0 factory_girl 4.5.0 ç®æ¬¡ 1. åææ¡ä»¶ 2. APIã®ä½æ 2.1. 1ã¤ã®ã³ã³ããã¼ã©ã¼ã§HTMLãJSONãè¿ãAPI 2.2. JSONã®ã¿ãè¿ãAPI 2.3. APIã®ãã¼ã¸ã§ãã³ã° 3. APIã®ãã¹ã 3.1. ãã¹ããã¡ã¤ã«ã®æºå 3.2. ä¸è¦§(index)APIã®ãã¹
ãã®è¨äºã§åããã㨠twitter-bootstrap 3.0ãRuby on Rails 4.0ã§åããæ¹æ³ã«ã¤ã㦠å 容 bootstrap 3.0ã«ã¤ã㦠twitter-bootstrap-railsã«ã¤ã㦠bootstrap 3.0 on rails 4.0 1.bootstrap 3.0ã«ã¤ã㦠bootstrapã¨ã¯ï¼ããã¨èª°ã§ãç°¡åã«æ´ã£ãã¬ã¤ã¢ã¦ãã®ãã¼ã ãã¼ã¸ãä½ããããã«ããããã®ç¡åã®ãã¼ã«ã§ãï¼ ç´°ãããã¨ã¯ããã¦ãããã¾ããï¼bootstrap ã使ã£ã¦æ§ç¯ããããµã¤ããä¹ã£ã¦ãã bootstrap-expoãè¦ã㨠ä½ã¨ãªãåããåããã®ã§ã¯ãªãããªã¼ã¨æãã¾ãï¼ ï¼ã¨ã¯è¨ããèªåã¬ãã«ã§ã¯bootstrapãã©ãã«ã¹ã¿ãã¤ãºããããã®ãããªã¬ãã«ã«ãªãã®ããã£ã±ãã§ããç¬ï¼ 使ãæ¹ã¯ç°¡åã§ï¼bootstrapã®å ¬å¼ãµã¤ãã®Getting Started
Railsåå¿è ãRailsã®ä¸éãã®ä»çµã¿ãç解ã§ãããã¨ãããã«ãRailsã®ä»çµã¿ãä¸ã¤ä¸ã¤ç解ããªããããã°ãä½æãã¦ããã¾ãã Railsã§ã®ã«ã¼ãã£ã³ã°ãã³ã³ããã¼ã©ã¼ãã¢ãã«ããã¥ã¼ã®è¦ç´ã使ãæ¹ãScssã§ã®ã¹ã¿ã¤ãªã³ã°ãCoffeeScriptã§ã®Javascriptã®è¨è¿°ãªã©ã説æãã¾ãã Rails Guide - Getting Started with Railsããã¼ã¹ã«ãã¾ããã ã¾ãã¯ãå®æãããããã°ã¢ããªã±ã¼ã·ã§ã³ã®ç»é¢ã§ãã åä½ç¢ºèª Ruby 2.0 Rails 4.1 Mac OS X 10.9 åææ¡ä»¶ Ruby ãã¤ã³ã¹ãã¼ã«æ¸ã¿ Rails 4 ãã¤ã³ã¹ãã¼ã«æ¸ã¿ SQLite3ãã¼ã¿ãã¼ã¹ãã¤ã³ã¹ãã¼ã«æ¸ã¿ â»ããã¤ã³ã¹ãã¼ã«ããã¦ããªãå ´åã¯ããRails4 ã¤ã³ã¹ãã¼ã«ããªã©ã§Googleæ¤ç´¢ãã¦ã¤ã³ã¹ãã¼ã«ãã¦ãã ãã ç®æ¬¡ Rail
Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? çµè«: Javascriptã®ä¹±ç¨ããããã®ãä¸çªã ã¯ããã«æ¸ãã¦ããã¾ãããããããªã話ã§ãã çµè«ãéçºè ã¨ãã¦ã¯ã©ã®ãããªæ¹åæ§ã§ããã¹ããããæ¸ãã¦ãã¾ãã JSå¤ãæ代ã§ã®ãã¬ã¼ã ã¯ã¼ã¯ã®æ ¹æ¬çãªåé¡äºã ã®ãã¨ã¯æ¸ãã¦ã¾ããã ãã¦ãç¾ç¶ãã¢ãã¤ã«ã«ããã¦ãJavascriptã§ã¾ã¨ãã«åããã®ãä½ããã¨ã¯é£ããã§ãã Twitterããå¼ãæããè¶ åªç§ãªWebã¨ã³ã¸ãã¢ãå¤æ°æ±ããMediumã§ãããæªã ã«ã¢ãã¤ã«ã§å¤æ°ã®ãã°ãæ±ãã¦ãã¾ãã è¶ åªç§ãªã¨ã³ã¸ãã¢ãä¸çä¸æ±ãã¦ããã§ãããGoogleã®Gmailã§ãããã¢ã
Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? è¿½è¨ Railsã§JSè¾ãåé¡ã«é¢ãã¦ã®çµè«ï¼http://qiita.com/kaiinui@github/items/dad6180f1910c6a4bfd5 -- è¿å¹´ã(1) Web/App両対å¿ãå¢ãã¦ãããã¨ã(2) Webã§ãJSãå¤ç¨ããããã«ãªã£ããã¨ãã®äºã¤ãããã以ä¸ã®ç¹ã§Railsãå¾®å¦ã«ãªã£ã¦ããã Viewã®JavascriptãRailsããç¬ç«ãã¦ãã API層ã®ãµãã¼ããå¾®å¦ æåã«æ¸ãã¦ããã¾ãããç¹ã«æ±ºå®çãªè§£æ±ºçããªããè¾ãããä»å¾è§£æ¶ããã¦ã»ããããããªè©±ã§ãã Viewã®Javascriptã
CSS .field_with_errors { @extend .has-error; } 解説 Railsã¯ã¨ã©ã¼ãåºããã©ã¼ã ã®æ¬ã«ãèªåã§field_with_errorsã¨ããã¯ã©ã¹ãä»ããã ãªã®ã§ãfield_with_errorsã«cssã追å ãã¦ããã°è¯ãã bootstrapã®cssãé©ç¨ããããã«ãsassã®@extendã使ãã @extendã«ã¯ãé©ç¨ãããã¹ã¿ã¤ã«ãæã¤bootstrapã®ã¯ã©ã¹ãæå®ãããããã§ã®å ´åãbootstrapã®.has-errorãé©ç¨ãã¦ããã ããã§ã¨ã©ã¼æã®CSSã«bootstrapã®CSSãé©ç¨ãããã¨ãã§ããã HTML æ¯è¼ ã¨ã©ã¼ãªã <div class="form-group"> <label class="control-label" for="user_name">Name</label> <input cla
ä»åã¯Rubyã®ä»£è¡¨çãªãã³ãã¬ã¼ãã¨ã³ã¸ã³ãhamlãã使ã£ã¦ãRailsã®Viewãæ¸ãæãã¦ã¿ã¾ããã¾ããHamlããã§ã«ä½¿ã£ã¦ãã人åãã«ãé©ããTipsçãªãã¼ãã·ã¼ããä½ãã¾ããï¼ ð Railsã®Viewã¨ã¯ï¼Railsã§ã¯æ¬¡ã®ãããªMVC(Model, View, Controller)ã®ããã¿ä½¿ã£ã¦Webã¢ããªã±ã¼ã·ã§ã³ãä½ã£ã¦ããã¾ãã Model(ã¢ãã«): 主ã«ãã¼ã¿ãã¼ã¹(MySQLãPostgreSQL)ã¨ã®ããã¨ããæ å½ View(ãã¥ã¼): 主ã«Webãã©ã¦ã¶ã®htmlã®è¡¨ç¤ºãæ å½ Controller(ã³ã³ããã¼ã©): View(ãã¥ã¼)ã¨Model(ã¢ãã«)ã¨ã®éã®æ©æ¸¡ããæ å½ ä»åã¯ãã©ã¦ã¶ã§ç°¡åã«ç¢ºèªã§ããViewã®é¨åãå¤æ´ãã¦ã¿ã¾ãã ð Hamlã¨ã¯ï¼ãHamlãã¨ã¯ç°¡åã«ããã¨HTMLãããç°¡åã«æ¸ãããã®ãã¥ã¼ãã³ãã¬ã¼ãã¨ã³ã¸ã³ã§ãã
Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? ã¯ããã« RSpecã¯é£ãããããããããªããã¨ãã£ãã³ã¡ã³ããã¨ãã©ãè¦ããã¾ãã 確ãã«ã¡ãã£ã¨ç¬ç¹ãªæ§æãæã£ã¦ãã¾ãããæ©è½ãçµæ§å¤ãã®ã§ãé£ããããã¨æãã¦ãã¾ãæ°æã¡ããããã¾ãã ï¼æ§æã«ã¤ãã¦ã¯åãæåè¦ãã¨ãã«ãããã£ããªããæ°æã¡ããã£ãã¨æã£ãè¨æ¶ãããã¾ãwï¼ ããããRSpecã«éããã©ããªãã¬ã¼ã ã¯ã¼ã¯ã§ãåãã§ãããæ £ãã¦ãã¾ãã°ã¹ã©ã¹ã©æ¸ãã¾ãããå®éåèªèº«ã¯ãRSpecã£ã¦ä¾¿å©ã ãªï¼ãã¨æããªãããã¹ãã³ã¼ããæ¸ãã¦ãã¾ãã ããã§ãã®è¨äºã§ã¯ãåãèãããæä½éããã ããæ¼ããã¦ããã°å¤§ä¸å¤«ï¼ï¼ããªR
ã¯ããã« ã¿ãªããããã«ã¡ã¯ï¼ ãã®è¨äºã¯ãå¿ è¦æå°éã®åªåã§æ大éå®æ¦ã§ä½¿ããç¥èãæä¾ããRSpecå ¥éè¨äºããç¥ãã¦ã使ããRSpecå ¥éãã®ç¬¬4åã§ãã ä»åã¯Capybaraã使ã£ããã£ã¼ãã£ã¹ããã¯ã«ã¤ãã¦èª¬æãã¾ãã ãã ããä»ã¾ã§ã®è¨äºã¨ã¯ç°ãªãããã£ã¼ãã£ã¹ããã¯ã®ã¤ããããããCapybaraã®ä½¿ãæ¹ãã«éç¹ãç½®ãã¾ãã ãªããªããåå人ã®çµé¨ãããã£ã¦ããã£ã¼ãã£ã¹ããã¯ã§å°ãã®ã¯ããã®ãã©ã¦ã¶ã®æä½ã£ã¦ãã©ããã£ã¦ã³ã¼ãã§è¡¨ç¾ããã®ï¼ï¼ãã¨ããã±ã¼ã¹ã大åã ããã§ãã ãã以å¤ã¯ç¬¬1åï½ç¬¬3åã®å 容ããã®ã¾ã¾å¿ç¨ã§ããã®ã§ãç¹ã«ããã£ã¼ãã£ã¹ããã¯ã ããå°ããã¨ãããã¨ã¯ãªãã¨æãã¾ãã ä»åã¯èª¬æãã主ãªé ç®ã¯ä»¥ä¸ã®éãã§ãã ãã£ã¼ãã£ã¹ããã¯ã®åºæ¬ ãã¼ã¸ã®ç§»åãç»é¢ã®ã¯ãªãã¯ããã©ã¼ã ã®æä½ãªã© ç»é¢ããã©ã¼ã ã®æ¤è¨¼ ç»é¢ã®æä½ãæ¤è¨¼ã®å¿ç¨ãã¯ãã㯠ãã®ä»
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}