Skip to content

Commit

Permalink
Goon
Browse files Browse the repository at this point in the history
  • Loading branch information
enderahmetyurt committed Jun 11, 2013
1 parent f660e99 commit 5227896
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions episodes/415 - Upgrading to Rails 4/tr.html
Expand Up @@ -97,5 +97,59 @@
# match 'new', to: 'episodes#new', via: [:get, :post]
get 'new', to: 'episodes#new'
```
<p>Spec'lerimizi çalıştırmayı denediğimiz zaman nedeni mass-assigning protected attributes olan bir çok hata ile karşılaşıyoruz. Bu hatalar Papertrail'ın <code>Version</code> modelinden geliyor. Bu durum Rails 4'de strong paramaters ile çalıştırılmalı fakat biz hala protected attributes kullanıyoruz. Uygulamamızın config dosyasını modifiye ederek başlayabiliriz. <code>active_record.whitelist_attributes</code> özelliğini <code>false</code> olarak ayarlıyoruz. Bu özellik başlangıçta <code>true</code> olarak geliyor ve bunu anlamı ise her model içinde <code>attr_accessible</code>'ın beklenmesidir. </p>

``` /config/application.rb
config.active_record.whitelist_attributes = false
```

<p>Bütün spec'lerimiz artık başarı ile geçiyor. Ancak buna rağmen hala uyarı mesajları alıyoruz. Bir kaçından kurtulmayı deneyelim. Bunların bir kısmı <code>whiny_nils</code> gibi artık desteklenmiyecek özelliklerin olduğu config dosyaları içinden geliyor. Development config dosyası içindeki <code>whiny_nils</code> alanı kaldırıp, yerine <code>eager_load</code> özelliğini ekliyoruz ve <code>false</code> olarak ayarlıyoruz. Daha fazla desteklenmeyecek diğer özellikleri de dosyadan kaldırabiliriz. </p>

``` /config/development.rb
Screencaster::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

config.eager_load = false

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log

# Expands the lines which load the assets
config.assets.debug = true
end
```
<p>Production modunu düzenleyeceğiz. Öncelikle bunu <code>config.assets.compress</code> ekliyoruz.</p>

``` /config/production.rb
config.eager_load = true

# Compress JavaScripts and CSS
config.assets.js_compressor = :uglifier
```
<p>Test ortamında ise <code>whiny_nils</code>'i kaldırmalı ve yerine eager'ı ekleyip <code>false</code> olarak ayarlamalıyız. <code>mass_assignment_sanitizer</code>'ı da strong paramters kullandığımız için kaldırmalıyız.</p>

``` /config/test.rb
# Log error messages when you accidentally call methods on nil
# config.whiny_nils = true
config.eager_load = false

# Raise exception on mass assignment protection for Active Record models
# config.active_record.mass_assignment_sanitizer = :strict
```





0 comments on commit 5227896

Please sign in to comment.